[Hibernate-JIRA] Created: (EJB-219) Add an EntityManagerFactory.getCurrentEntityManager() method.
by James Olsen (JIRA)
Add an EntityManagerFactory.getCurrentEntityManager() method.
-------------------------------------------------------------
Key: EJB-219
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-219
Project: Hibernate Entity Manager
Type: New Feature
Components: EntityManager
Environment: Hibernate 3.2. Any/All.
Reporter: James Olsen
BACKGROUND
I'd like to code against the JPA standard, however my current EJB container vendor (like many others) is only providing JPA support as part of their EJB3 rollout which is at a very early stage.
JPA doesn't need a full EJB3 environment. The only required apsect that appears to be missing in existing EJB containers is container management and injection of a correctly scoped EntityManager. I can deal with the injection problem by having a Singleton accessor for the EntityManagerFactory in much the same way as the well known HibernateUtil deals with the SessionFactory. All that is left then is providing something similar to the automatic JTA/CMT context scoping of Sessions for EntityManager instances.
SUGGESTION
I would propose that a new custom API be added to org.hibernate.ejb.EntityManagerFactoryImpl in the form of a method called getCurrentEntityManager(). Internally this would construct an EntityManagerImpl that was configured to do sessionFactory.getCurrentSession() rather than sessionFactory.openSession() (inside the getRawSession() method), thereby leveraging Hibernates pre-existing capability to return correctly scoped units of work in a JTA/CMT environment. Thats sounds easy, but maybe there's more to it!?
JUSTIFICATION
The advantage of having such an API is that we can write to the JPA API without waiting for full EJB3 support in the container. The little bit of application code to obtain the EntityManagerFactory, cast to the Hibernate impl and call this custom method can easily be removed in the future when EntityManager injection is available.
I've looked at using Spring and Pitchfork but as great as they are, they are heavy handed when you already have a container and my customer demands a container and also has an aversion to non GA code (implies I'm confident the Hibernate 3.2 products will be GA soon - which I am!).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years, 3 months
[Hibernate-JIRA] Created: (HBX-728) Patch for hbm2dao "No signature of method getJavaTypeName matches (java.lang.Object,java.lang.Boolean) "
by Jacob Bergoo (JIRA)
Patch for hbm2dao "No signature of method getJavaTypeName matches (java.lang.Object,java.lang.Boolean) "
--------------------------------------------------------------------------------------------------------
Key: HBX-728
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-728
Project: Hibernate Tools
Type: Patch
Components: reverse-engineer
Versions: 3.2beta6
Environment: Hibernate tools beta6, Eclipse 3.2, Ant 1.6.5, Windows XP, Hibernate 3.1
Reporter: Jacob Bergoo
This is the fix for this error message:
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2dao (Generates a set of DAOs)
[hibernatetool] log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
[hibernatetool] log4j:WARN Please initialize the log4j system properly.
[hibernatetool] An exception occurred while running exporter #2:hbm2dao (Generates a set of DAOs)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.tool.hbm2x.ExporterException: Error while processing template daohome.ftl
[hibernatetool] freemarker.template.TemplateModelException: No signature of method getJavaTypeName matches (java.lang.Object,java.lang.Boolean)
to fix this you need to edit your dao templates you are using to generate the code. For the method findById() you have a if statement
<#if clazz.identifierProperty>
simply change this one to:
<#if clazz.identifierProperty?has_content>
and it should work.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years, 3 months