-->
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.  [ 2 posts ] 
Author Message
 Post subject: Conguration questions of Hibernate 3
PostPosted: Sat Apr 23, 2005 12:17 pm 
Newbie

Joined: Wed Apr 20, 2005 4:37 pm
Posts: 6
I am just starting out with Hibernate and I am using Hibernate 3.0.1. I have a couple of configuration questions:

1. I want to store the <mapping> tags in a different file. If I do the following, will the properties or settings be merged?

Code:
String mainConfigFile = "/web/etc/hibernate.cfg.xml";
String mappingConfigFile = "/web/etc/hibernate.mapping.xml";

Configuration config = new Configuration();
config.configure(new File(mainConfigFile));
config.configure(new File(mappingConfigFile));
SessionFactory factory = config.buildSessionFactory();


2. When defining the mappings in the hibernate.cfg.xml file, is it possible to specify either a root directory (the top level directory of my application class path; used when developing) or specify a Jar file (used in production) so Hibernate can scan for the "*.hbm.xml" files?

I looked in the "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"
and I saw the following attributes of the mapping tag:

Code:
<!ELEMENT mapping EMPTY> <!-- reference to a mapping file -->
<!ATTLIST mapping resource CDATA #IMPLIED>
<!ATTLIST mapping file CDATA #IMPLIED>
<!ATTLIST mapping jar CDATA #IMPLIED>
<!ATTLIST mapping package CDATA #IMPLIED>
<!ATTLIST mapping class CDATA #IMPLIED>


But, the only one that worked is the "resource" to specify a specific ".hbm.xml" file. I experimented with the other attributes and they all threw a errors like this:
Quote:
[2005-04-22 21:03:52.209] com.caucho.config.LineConfigException: conf/resin.conf:278: org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping package="com.marinersupply.authentication"/>


thanks for your help


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 24, 2005 12:08 am 
Beginner
Beginner

Joined: Wed Apr 20, 2005 9:30 am
Posts: 39
You can specify the mappings in your hibernate.cfg.xml, like so:

<mapping resource="com/foo/bar/Things.hbm.xml" />


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