-->
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: hibernate.cfg.xml property names
PostPosted: Mon Dec 29, 2003 12:52 pm 
Beginner
Beginner

Joined: Mon Dec 29, 2003 12:49 pm
Posts: 41
Location: Boston, MA
I've a general question regarding setting Hibernate properties when using hibernate.cfg.xml. What are (if any) valid property names for not only the root element <hibernate-configuration> but for <session-factory> as well? In other words, I want to be able to set thehibernate.query.substitutions or the hibernate.jdbc.fetch_size values in my xml config file. Are they just the name of the property in hibernate.properties sans the "hibernate" prefix? For example:


Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
    PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
    <property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>

    <session-factory>

        <property name="connection.datasource">java:comp/env/jdbc/scapeDB</property>
        <property name="show_sql">false</property>
        <property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
        <property name="batch_size">25</property>
        <property name="use_outer_join">true</property>

        <!-- Mapping files -->
        <mapping resource="scape.hbm.xml"/>

    </session-factory>

</hibernate-configuration>



I haven't been able to find any info on valid property names (the DTD wasn't helpful in this regard). I know that the API allows you to set properties programmatically after instantiation of a Configuration object, but I haven't been able to find any examples. Perhaps this is the rout I need to go, but again... what are valid property names?

Code:

Configuration config = new Configuration();
config.setProperty("batch_size", "25");

sessionFactory = config.configure().buildSessionFactory();


My question here as well is if, as the javadoc states, "A new Configuration will use the properties specified in hibernate.properties by default" does the use of the constructor preclude me from using the values in hibernate.cfg.xml? At what point are the properties for the Configuration object read? I assume it is on construction....

Thanks!

_________________
Brian R. Wainwright
Systems Developer
WGBH Educational Foundation

"WGBH Boston informs, inspires, and entertains millions through public broadcasting, the Web, and educational multimedia, and access services for people with disabilities."


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 29, 2003 1:36 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
net.sf.hibernate.cfg.Environment contains the keys of available properties.
Quote:
does the use of the constructor preclude me from using the values in hibernate.cfg.xml? At what point are the properties for the Configuration object read? I assume it is on construction....

No,
hibernate.properties is read once for the lifetime of the JVM
hibernate.cfg.xml is read every single time you call configuration.configure();
properties are overriden except those considered as System level (see the reference guide).

Have a look a the net.sf.hibernate.cfg package for more infos

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 31, 2003 1:51 am 
Beginner
Beginner

Joined: Fri Dec 26, 2003 3:21 pm
Posts: 23
Location: Jakarta
So, we can use hibernate.cfg dynamicall? mm I thin about xfg.xml manager, so we can modify it every time we execute the persistance.

is it right?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 31, 2003 4:29 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hum every time you recall configure(). But you have to build a new session factory and new sessions. It's not that transparent

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 01, 2004 2:42 am 
Beginner
Beginner

Joined: Fri Dec 26, 2003 3:21 pm
Posts: 23
Location: Jakarta
I read in Mc Laughlin book, Java XML from Orielly. He wrote a XMLProperties. I think Hibernate use it too right. But why dont decouple it, It is a cool code I think.

I found that Hiberante use JDOm too. same with XMLProperties from Mc Laughlin.

Jive Forum use that too.

Is the mechanism look like this


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 01, 2004 2:08 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hibernate core don't use jdom anymore - it uses dom4j. ....and a new way to read properties does not solve the actual problem ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 02, 2004 7:57 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Dynamical hot relading of properties is easy.
Dynamical hot-reloading of the mapping and Hibernate metadata (built from properties) isn't at all.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: hibernate.cfg.xml property names, using Jboss SAR
PostPosted: Mon Jan 05, 2004 2:43 am 
Hi,


IN the context of Jboss 3.2.1,(Hiberate 2.0) I want to persist Boolean property of an object to an integer column, where 1/0 corresponds to true/false. I understand I need to set property:

hibernate.query.substitutions to true 1, false 0, yes 'Y', no 'N'

Given that Jboss SAR deployment has a jboss-service.xml file instead of a config file, how does one edit the fjboss-service in order to set the property hibernate.query.substitutions


thanks in advance,

Eliot


Top
  
 
 Post subject:
PostPosted: Mon Jan 05, 2004 12:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Using Hibernate 2.1.1 you can set this using

Code:
<attribute name="QuerySubstitutions">...</attribute>

You can't with 2.0 however.


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.