-
1. Re: Help with Hibernate on Seam
gaborj Apr 8, 2010 8:04 PM (in response to faprieto)Of course it is possible, did you check the hibernate example included with the seam distribution examples directory? Anyway, you sure you need the SessionFactory? In most cases you simply inject hibernate Session and you do not care about the Factory managed by the framework, it is much simpler...
-
2. Re: Help with Hibernate on Seam
faprieto Apr 9, 2010 3:16 PM (in response to faprieto)thanks Gabor...
I need specifically the SessionFactory to instantiate another class from another API... I do not use directly the Session object... that API does it.
I have review the hibernate example included with seam, and i saw following details:in components.xml:
... <persistence:hibernate-session-factory name="*hibernateSessionFactory*"/> <persistence:managed-hibernate-session name="*myprojectDatabase*" auto-create="true"/> ...
in hibernate.cfg.xml:
<session-factory name="java:/*myprojectDatabase*"> ...
and nothing else... i thinks that it´s enough to do this:
@Name("somename") class XXX{ @In private Session *myprojectDatabase*; @In private SessionFactory *hibernateSessionFactory*; }
although i only need this:
@Name("somename") class XXX{ @In private SessionFactory *hibernateSessionFactory*; void somemethod(){ classFromAPI(hibernateSessionFactory); } }
I will test both...
Although, one of many error that i got was that the hibernate.cfg.xml and the mapping.hbm.xml (specified inside the .cfg) were not found.
Where should i copy both files? on resources dir?i am using Eclipse Ganymede, JBoss Tools Win32 3.0.0.GA-R200903141626-H5, Seam 2.1.1.GA and Jboss GA 4.2.2, if there is some related bug.
I appreciate your concern... thanks again Gabor...
Cheers... -
3. Re: Help with Hibernate on Seam
gaborj Apr 12, 2010 5:39 AM (in response to faprieto)Yes, first let Hibernate parse your settings and mappings. The .cfg.xml goes into resources in dev environment in this file you can refer to all your mapping files, look at some jBPM example e.g. the DVDStore... after successful bring-up you can retrieve reference to factory as
- injection
- Component.getInstance(<nameofComponentOrClassDef>)
- directly from JNDI tree
...