Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0003429 [Resin] minor always 03-01-09 13:13 08-26-09 14:28
Reporter ferg View Status public  
Assigned To ferg
Priority normal Resolution fixed Platform
Status closed   OS
Projection none   OS Version
ETA none Fixed in Version 4.0.2 Product Version
  Product Build
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
Attached Files

- Relationships

- Notes
(0004172)
ferg
08-26-09 14:28

support/0604
 

- Issue History
Date Modified Username Field Change
03-01-09 13:13 ferg New Issue
04-29-09 14:51 skot Issue Monitored: skot
08-26-09 14:28 ferg Note Added: 0004172
08-26-09 14:28 ferg Assigned To  => ferg
08-26-09 14:28 ferg Status new => closed
08-26-09 14:28 ferg Resolution open => fixed
08-26-09 14:28 ferg Fixed in Version  => 4.0.2


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
30 total queries executed.
26 unique queries executed.
Powered by Mantis Bugtracker