-->
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.  [ 5 posts ] 
Author Message
 Post subject: Properties of a Hibernate (2.1.3) configuration
PostPosted: Wed Jul 26, 2006 11:14 am 
Newbie

Joined: Wed Jul 26, 2006 10:35 am
Posts: 11
While investigating the properties within a configuration instance I discovered that each property is stored twice, once with a 'hibernate.'-prefix and once without. Every non-hibernate environment property comes in these two variants as well.

Going through the hibernate source I couldn't exactly figure out which variant of a property is used for which purpose. As far as I can see the constants within the environment class all have the 'hibernate.'-prefix and are used to build the session factory.

What are the properties without the 'hibernate.'-prefix used for?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 26, 2006 11:26 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
huh?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 27, 2006 2:53 am 
Newbie

Joined: Wed Jul 26, 2006 10:35 am
Posts: 11
Hmmm, maybe my topic start wasn't entirely clear. Let me explain by giving an example.

I have a configuration specified in a hibernate.cfg.xml as follows:

Code:
<hibernate-configuration>
    <session-factory>
        <property name="show_sql">false</property>
        <property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>

        <property name="connection.isolation">2</property>
        <property name="connection.url">jdbc:oracle:thin:@my_host:1521:my_db</property>
        <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>

        <property name="connection.username">my_user</property>
        <property name="connection.password">my_pwd</property>

        <property name="maxActive">30</property>
        <property name="maxIdle">10</property>
        <property name="maxWait">-1</property>

        several mappings ...
    </session-factory>
</hibernate-configuration>


This file is used to make the configuration by constructing a instance of Configuration using the properties from above.

Now having a Configuration instance myConfig I make the method call myConfig.getProperties() and log its contents by iterating through all properties. The output I get consists of every property as I defined it together with a second variant where the name is prefixed with 'hibernate.':

(<property name> = <value>)
show_sql = false
hibernate.show_sql = false
dialect = net.sf.hibernate.dialect.Oracle9Dialect
hibernate.dialect = net.sf.hibernate.dialect.Oracle9Dialect

et cetera.

In addition, all my environment properties are listed as well:

java.vendor = Sun Microsystems Inc.
hibernate.java.vendor = Sun Microsystems Inc.

et cetera.

All this awoke my curiosity about which property is used to which purpose.

The Hibernate properties are used when building the SessionFactory. In the Environment class all property names are defined as String constants, where every constant is of the form "hibernate.<property>", among which the properties defined in my hibernate.config.xml as for example the constant DIALECT = "hibernate.dialect".

Now I'm curious for which purpose the properties that are not prefixed by 'hibernate.' are used as well as the purpose the system properties serve (including their 'hibernate.<system_property>' equivalent.

I hope this post makes some more sense than the first :)


Last edited by Rens on Thu Jul 27, 2006 2:59 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 27, 2006 2:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well it is you who are using the "shorthand" version of the property names which hibernate then converts to the full fledged version because they are found in a hibernate.cfg.xml.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 27, 2006 3:17 am 
Newbie

Joined: Wed Jul 26, 2006 10:35 am
Posts: 11
Ah, and now that I got my head clear again in these first five minutes of a new working day I see that the 'hibernate.'-system properties are just the produce of my buggy code.

Damn, it really must have been hot in here yesterday...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.