• Post Reply Bookmark Topic Watch Topic
  • New Topic

Where do I get the entityManagerFactory?  RSS feed

 
Vadim titsi
Greenhorn
Posts: 14
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Where do I get the entityManagerFactory? If I use the org.hibernate.SessionFactory. I don't use the JPA. I know that it would be worth it but it's too late.
Solution on the stackoverflow:
Use the hibernate EntityManager. But the http://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager/5.2.9.Finalmaven-suite says: hibernate-entitymanager  - (deprecated - use hibernate-core instead) Hibernate O/RM implementation of the JPA specification  and Files Download (JAR) (591 bytes) .
Is this a dead end?

I just want to run this code:
 
Vadim titsi
Greenhorn
Posts: 14
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So it is more correct:
QueryBuilder qb = fullTextEntityManager.getSearchFactory()
                .buildQueryBuilder().forEntity(Comment.class).get();
 
Rob Spoor
Sheriff
Posts: 21095
85
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using a JEE container like JBoss/WildFly, WebLogic, etc, you can inject it:

If not, then you can use the Persistence class:

In both cases, the persistenceUnitName must match the persistence unit name from your persistence.xml file.
 
Vadim titsi
Greenhorn
Posts: 14
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have only a file with name - hibernate_loc.cfg.xml:
....
<mapping resource="Comment.hbm.xml" />
...

That's the right decision?
Persistence.createEntityManagerFactory("Comment");

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!