Open heftyy opened 9 years ago
I have the same problem. Any issue?
Try updating your dependencies in your build.sbt from http://mvnrepository.com/
Any idea? I have tried to update the hibernate em/spring framework/spring data jpa dependencies, but it still failed with the same problem.
facing the same issue. an updates please?
This is because of the new DI design in play 2.4, which use guice as the main DI implementation. Try using spring-guice module for integrate spring into the system. The first solution I have seen is play24-guice-spring.
I managed to get it working with spring-guice
but it failed to get EntityManager
throwing following exception:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: At least one JPA metamodel must be present!
so I gave up....
Hi @eximius313,
I had the similar issues, maybe me pull request https://github.com/typesafehub/play-spring-data-jpa/pull/20 can help you.
Cheers Johannes
Annotate your PersonRepository interface with @ImplementedBy..
@ImplementedBy(PersonRepositoryImpl.class)
public interface PersonRepository {
//method declarations
}
@eximius313 Did you try adding the JPA meta model generator ref?
https://docs.jboss.org/hibernate/orm/5.0/topical/html/metamodelgen/MetamodelGenerator.html
@unterstein I'm using PostgreSQL. Play requires me to use persistence.xml file. However, in your implementation you are using AnnotationConfiguration. Can these both solutions coexist?
Kind regards
@eximius313,
sure. I just used programmatically configuration because i eliminated Ebean and it was far easier this way.
You could do something like this:
Configuration
@Configuration
@EnableJpaRepositories("models")
public static class SpringDataJpaConfiguration {
@Bean
public EntityManagerFactory entityManagerFactory() {
return Persistence.createEntityManagerFactory(DEFAULT_PERSISTENCE_UNIT);
}
@Bean
public HibernateExceptionTranslator hibernateExceptionTranslator() {
return new HibernateExceptionTranslator();
}
@Bean
public JpaTransactionManager transactionManager() {
return new JpaTransactionManager();
}
}
persistence.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<!-- postgres -->
<persistence-unit name="default">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.archive.autodetection" value="class" />
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver" />
<property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432/querydsl" />
<property name="hibernate.connection.username" value="querydsl" />
<property name="hibernate.connection.password" value="querydsl" />
<!-- <property name="hibernate.show_sql" value="true"/> -->
<property name="hibernate.flushMode" value="FLUSH_AUTO" />
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
</persistence>
I took the persistence.xml configuration from https://gist.github.com/mortezaadi/8619433. You should adapt this configuration according to your needs.
Kind regards Johannes
@unterstein is is necessary to remove javaJpa
from libraryDependencies
in build.sbt
file?
@eximius313 I think this dependency was not available anymore..
Well, I'm using it now and it allows for using JPA in my project. Why would it be not available?
If it is available and you need classes from this dependency, just use it :-).
I don´t know why i removed this dependency to be honest...but in this case, spring data provides all relevant jpa dependencies :)
I have been trying to use this example with play 2.4 but i am getting this error: No implementation for models.PersonRepository was bound. It works fine until play 2.3.9