[hibernate-issues] [Hibernate-JIRA] Resolved: (EJB-285) EJB3 compliant default settings override hibernate.cfg.xml
Emmanuel Bernard (JIRA)
noreply at atlassian.com
Tue Jan 15 18:49:56 EST 2008
[ http://opensource.atlassian.com/projects/hibernate/browse/EJB-285?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Emmanuel Bernard resolved EJB-285.
----------------------------------
Resolution: Won't Fix
You analysis is quite good. But that's a choice I made. I would rather force the user to override a non compliant property in persistence.xml rather than letting him be fooled by a cfg.xml which makes his application non compliant "by mistake".
The solution is to set the sensitive property(ies) in persistence.xml
> EJB3 compliant default settings override hibernate.cfg.xml
> ----------------------------------------------------------
>
> Key: EJB-285
> URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-285
> Project: Hibernate Entity Manager
> Issue Type: Bug
> Components: EntityManager
> Affects Versions: 3.3.1.GA
> Environment: Hibernate 3.2.1
> Hibernate EntityManager 3.3.1.GA
> Reporter: Rodolfo Federico Gamarra
> Priority: Minor
> Attachments: entitymanager-configuration.zip
>
> Original Estimate: 4 hours
> Remaining Estimate: 4 hours
>
> Hi, I think I've found a little bug in org.hibernate.ejb.Ejb3Configuration ($Id: Ejb3Configuration.java 11344 2007-03-25 18:24:01Z epbernard $) class.
> Hopefully the title is clear enough to describe what's happening:
> - I've a persitence.xml which references (via "hibernate.ejb.cfgfile") a hibernate.cfg.xml, in the way that's described, for example, in the Entity Manager User Guide (Version: 3.3.1.GA. Page 8, below "Here is a typical configuration in a J2SE environment").
> - In the referenced xml I set the auto commmit property in false and in persistence.xml nothing it's said about that property.
> - What I see at the end of the startup is that the value is true.
>
> Posible explanation:
> - Take a look at Ejb3Configuration, specially the methods:
> - configure(Properties properties, Map workingVars)
> - prepareProperties(Properties properties, Map workingVars)
> - A pseudo-code for the first may be:
> 1) Prepare properties (load persistence.xml):
> //settings that always apply to a compliant EJB3
> preparedProperties.setProperty( Environment.AUTOCOMMIT, "true" );
> 2) Load the referenced "hibernate.ejb.cfgfile".
> I saw in debugging that the actual false value gets loaded.
> 3) Priorize persistence.xml over hibernate.cfg.xml:
> cfg.addProperties( preparedProperties ); //persistence.xml has priority over hibernate.Cfg.xml
>
> The problem with the last line (besides the typo in the comment, in the extension :-)) is that, I think, that priorization doesn't consider that maybe the values in the prepared properties are there because a default (and not because they were acctually configured in the xml).
> After reading "READ THIS BEFORE USING JIRA!", I took a look in the already reported things but didn't get to the problem (In fact, I was using an older verion and, so, I made an update and tried with the lattest one). Also, as you say "Don't attach your project folder as a Zip file, but only the relevant files. Please don't upload them one-by-one, but packaged in a Zip": I made a dummy project (Eclipse 3.2) which shows the problem. I setup log4j properties into debug mode, where the beforementioned can be saw. Also I added some reflection code in order to see the configuration values after the startup process has finished. I also used some other properties in order to have some combinations: a property defined in both xmls (persistence wins), just in persistence, just in hibernate and gets overrided (autocommit), just in hibernate but doesn't get overrided (user name). I hope that I didn't misundertood "...don't attach your project...", what I attached is a tiny-example-oriented project; from which the relevant files are "persistence.xml" and "hibernate.cfg.xml".
> In the heading of the log (which is in root of the project in console.txt) you can see the versions of Hibernate, in particular Hibernate EntityManager 3.3.1.GA.
--
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