[hibernate-issues] [Hibernate-JIRA] Resolved: (EJB-250) Ejb3Configuration class issue
Emmanuel Bernard (JIRA)
noreply at atlassian.com
Mon Feb 19 14:48:47 EST 2007
[ http://opensource.atlassian.com/projects/hibernate/browse/EJB-250?page=all ]
Emmanuel Bernard resolved EJB-250:
----------------------------------
Assign To: Emmanuel Bernard
Resolution: Duplicate
Dupe of EJB-257
> Ejb3Configuration class issue
> -----------------------------
>
> Key: EJB-250
> URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-250
> Project: Hibernate Entity Manager
> Type: Bug
> Versions: 3.2.0.ga
> Environment: Hibernate version : 3.2.0.ga.
> Db : H2
> Reporter: David Avenante
> Assignee: Emmanuel Bernard
> Priority: Minor
>
>
> Hi,
> I try for my test to use my entityManager out of container.
> For that i instanciate my entityManagerFactory through the Ejb3Configuration helper.
> All it's ok (annoted classes found, connection ok ...) but not my transactionType !!!!
> i try to add the property "javax.persistence.transactionType" ->"RESOURCE_LOCAL" without success
> After inspection of sources it's seem this property is available through the configure() method who need the name of a file configuration.
> But i don't want that a want define my entityManager only programaticly.
> Ok so after some investigations.
> Ejb3Configuration cfg = new Ejb3Configuration();
> cfg.addProperties(getProperties());
> cfg.addAnnotatedClass(User.class);
> entityManagerFactory = cfg.buildEntityManagerFactory();
> private static Properties getProperties() {
> Properties properties = new Properties();
> properties.setProperty(Environment.DRIVER, DATABASE_DRIVER_CLASS);
> properties.setProperty(Environment.URL, MEMORY_DATABASE_URL);
> properties.setProperty(Environment.USER, USERNAME);
> properties.setProperty(Environment.PASS, PASSWORD);
> properties.setProperty(Environment.DIALECT, DBDIALECT);
> properties.put(Environment.SHOW_SQL, "true");
> properties.put(Environment.FLUSH_BEFORE_COMPLETION, "false");
> properties.put(Environment.TRANSACTION_STRATEGY, PersistenceUnitTransactionType.RESOURCE_LOCAL);
> properties.put(Environment.HBM2DDL_AUTO, "create");
> return properties;
> }
> This code don't work because my entityManagerFactory doesn't have TransactionStrategy attached.
> But if i use this code
> Ejb3Configuration cfg = new Ejb3Configuration();
> cfg.addProperties(getProperties());
> cfg.addAnnotatedClass(User.class);
> cfg.configure("hibernate.cfg.xml");
> entityManagerFactory = cfg.buildEntityManagerFactory();
> with a empty hibernate.cfg.xml config file like that ...
> <?xml version='1.0' encoding='utf-8'?>
> <!DOCTYPE hibernate-configuration PUBLIC
> "-//Hibernate/Hibernate Configuration DTD//EN"
> "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
> <hibernate-configuration>
> <session-factory>
> </session-factory>
> </hibernate-configuration>
> the entityManagerFactory have a transaction manager attached !!!!
> You can reply me hey guys all is ok good but not really. Because we can see the cfg.configure("hibernate.cfg.xml") don't use a resource or an input stream but a string. So the location of my file must be in my source directory but i dont want that. I want to use my file in my test directory tree.
> So emmanuel ask me to open and issue ;)
--
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.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list