-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: Problem with setProperties and useReflectionOptimizer
PostPosted: Thu Nov 06, 2003 2:20 pm 
Newbie

Joined: Sat Aug 30, 2003 6:31 pm
Posts: 6
Location: Pforzheim / Germany
Hi everybody,

I like to store the hibernate.properties in the same place as my other application configuration (xml files with mappings, pageflows, localization and so on in a central config directory) and therefore at app startup I use the setProperties() method of the Configuration class of 2.x (I use Version 2.1b4).

So far so good, but after a view test I think hibernate ignores at minimum one property setting if used this way. The property is

Code:
hibernate.cglib.use_reflection_optimizer false


The effect is as follows. If I place the properties file in the classpath hibernate finds and use it (inclusive the reflection_optimizer property!) after the call of

Code:
Configuration cfg = new Configuration();


and all works fine. If I store hibernate.properties in my config directory and run the following code

Code:
Configuraton cfg = new Configuration();
cfg.setProperties(myProp);


Hibernate writes to my log (after the first line) "hibernate.properties not found". After that I see while I debug it, that the properties are there and correct. In my case the reflection_optimizier is set to false, BUT


Code:
Environment.useReflectionOptimizer()


returns TRUE!!

This seems to me like a bug, am I right ?

THX for infos in advance.

Klaus


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 06, 2003 2:57 pm 
Regular
Regular

Joined: Tue Sep 16, 2003 11:35 am
Posts: 93
Location: San Francisco, CA
you have a '=' between hibernate.cglib.use_reflection_optimizer and false right?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 06, 2003 3:01 pm 
Newbie

Joined: Sat Aug 30, 2003 6:31 pm
Posts: 6
Location: Pforzheim / Germany
No I haven't. Its exactly as I posted it. The properties are correct loaded in the myProp object and set to the Configuration object. But it doesn't change the reflection_optimizer value in the Environment.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 06, 2003 7:51 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Would say this is a bug since ENABLE_REFLECTION_OPTIMIZER is Environment Level and not Settings level. But there might be a reason I can't find.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 06, 2003 9:23 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
hibernate.cglib.use_reflection_optimizer is a system level property, as per the documentation.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 07, 2003 5:51 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Quote:
System-level properties can only be set via java -Dproperty=value or be defined in hibernate.properties and not with an instance of Properties passed to the Configuration


Missed that line until now. It is not a bug, it's a feature ;-)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 07, 2003 6:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
A mis-feature actually, but one thats stupidly difficult to fix.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 07, 2003 8:32 am 
Newbie

Joined: Sat Aug 30, 2003 6:31 pm
Posts: 6
Location: Pforzheim / Germany
Thanks for the info. I will put my properties file back to the classpath.

By the way in my opinion it would be better to disable the reflection optimizer per default, because of the problem / restriction with the private setter/getter methods. I find for new users it would make the usage of hibernate easier, because if you follow the docs and best practices you would declare methods like setId(...) for example as private and then at application startup get the IllegalArgumentException caused by ReflectHelper.getMetaClass or exactly CGLIB as I wrote in another thread here.

The migration for hibernate 1.2.x users, which doesn't know CGLIB - as I - would be easier with this change, too. Not that I think the migration was difficult - beside this problem I have had no trouble and it was much easier than expected and works fine as before.

Therefore I think it would be better to disable the optimizer per default or if this is not possible / wanted to add a hint to the point 3.1.1 of the docs
(http://www.hibernate.org/hib_docs/refer ... classes-s1).

What do you think about that ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 07, 2003 9:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
But the reflection optimizer automatically disables itself if the exception occurs. That exception is completely nonfatal.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.