Mantis - Resin
|
|||||
Viewing Issue Advanced Details | |||||
|
|||||
ID: | Category: | Severity: | Reproducibility: | Date Submitted: | Last Update: |
3429 | minor | always | 03-31-09 13:13 | 08-26-09 14:28 | |
|
|||||
Reporter: | ferg | Platform: | |||
Assigned To: | ferg | OS: | |||
Priority: | normal | OS Version: | |||
Status: | closed | Product Version: | |||
Product Build: | Resolution: | fixed | |||
Projection: | none | ||||
ETA: | none | Fixed in Version: | 4.0.2 | ||
|
|||||
Summary: | 0003429: @Service, JPA/Hibernate, and inserting | ||||
Description: |
(rep by Scott Hernandez) I want to have services (that start with the application, and runs the length of the application lifetime) so I define a POJO with a @Service and a method with a @PostConstruct. Everything is going well so far. I define a persistenceunit in persistence.xml and corresponding jdbc info in the (resin-)web.xml config. So my service looks like this: @Service public class InitDBService { @PersistenceContext protected EntityManager em; @PersistenceUnit protected EntityManagerFactory emf; @PostConstruct public void postConstruct() { log.log(Level.INFO, "emf=" + emf + " em=" + em); if (emptyDB()) insertDefaultData(); } } emf=AmberEntityManagerFactory[amber] em=EntityManagerProxy[amber] So I load up my webapp and away it goes. If I use amber (the native JPA impl) everything looks fine and the entity manager, and factory is injected as expected, and the data is queried (and inserted if empty). Now, if I switch to a hibernate backed persistenceunit (hbm) I get some kind of exception no matter how I do it. emf=null em=EntityManagerTransactionProxy[hbm,null] I have tried using @TransactionAttributes, the UserTransaction object, and various other attempts without any success on the hibernate persistenceunit. Now, later in my code, in a servlet, I have the same code and it runs fine against the @PersistenceContext using the hibernate persistenceunit. I hope this makes a bit more sense and maybe someone can point me in the right direction to get this working :) |
||||
Steps To Reproduce: | |||||
Additional Information: | |||||
Relationships | |||||
Attached Files: |
Notes | |||||
|
|||||
|
|