-->
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.  [ 6 posts ] 
Author Message
 Post subject: storing hibernate mapping files outside the classpath.
PostPosted: Mon Nov 08, 2004 6:16 pm 
Beginner
Beginner

Joined: Thu Oct 14, 2004 10:53 pm
Posts: 45
[b]Hibernate version:2.1.4[/b]

[b]Mapping documents:[/b]

<hibernate-configuration>
<session-factory>

<!-- Properties -->
<property name="hibernate.dialect">net.sf.hibernate.dialect.SQLServerDialect</property>
<property name="hibernate.connection.driver_class">com.inet.tds.TdsDriver</property>
<property name="hibernate.connection.url">jdbc:inetdae:CONTRACT1:1433?database=CDRAaron</property>
<property name="hibernate.connection.username"></property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.show_sql">true</property>

<!-- Mapping resources -->
<mapping resource="resources/Address.hbm.xml"/>
<mapping resource="resources/Identifier.hbm.xml"/>
<mapping resource="resources/Name.hbm.xml"/>
<mapping resource="resources/Patient.hbm.xml"/>
<mapping resource="resources/TelecommunicationNumber.hbm.xml"/>


</session-factory>

</hibernate-configuration>

I want to store my hibernate mapping files outside of my classpath. My hibernate mapping files are stored in a directory called conf/resources, which is outside my classpath. My hibernate.cfg.xml file is stored another level up in the conf folder. Hibernate can locate the hibernate.cfg.xml file when I specify the path to the conf directory. However hibernate can't seem to locate these mapping files. When I put the resources folder in my classpath, hibernate can find them, but I really want to store the mapping files outside the classpath. How can I resolve this directory issue??


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 7:01 pm 
Beginner
Beginner

Joined: Sun Oct 03, 2004 8:50 am
Posts: 32
Location: McLean, VA
An option is to do something like this:
Code:
Configuration config = new Configuration()
config.addDirectory(new File(pathToDirectoryWithMappings));
SessionFactory sessionFactory = config.buildSessionFactory();

_________________
- Chad


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 7:09 pm 
Beginner
Beginner

Joined: Thu Oct 14, 2004 10:53 pm
Posts: 45
Thanks for that.

what I have done is in my hibernate.cfg.xml file I changed <mapping resource=resources/mapping file> to <mapping file=full path of mapping file>

I'm not sure if putting the full path of the mapping file is recommended. Is there a way to put the relative file path????????


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 7:36 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
have you tried to just do it ?

we just do new File(filename) on it - so it is relative to the vm current dir.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 8:24 pm 
Beginner
Beginner

Joined: Thu Oct 14, 2004 10:53 pm
Posts: 45
Im not sure that I understood your post. I really need to use a relative path instead of the absolute path. It appears that if you use the resource=, hibernate searches the class path for the resource directory. I want the resource directory outside of the classpath. You can do this by specifying file= instead of resource=, but I don't know how to set the relative path there. Can you advise me?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 09, 2004 3:36 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
The path you specify in your mapping is just passed to new File(xxx). Please read the Java API.


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