-->
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.  [ 1 post ] 
Author Message
 Post subject: Dynamic configuration discovery from hbm.xml?
PostPosted: Wed Sep 14, 2005 10:46 am 
Newbie

Joined: Wed Dec 22, 2004 11:36 am
Posts: 11
I am trying to setup Hibernate with programmatic configuration. I would like to use addClass so that I can use reflection in my code (so I don't have to specify each class explicitly or specify the configuration file names). However, some classes reference other classes. For example...

<hibernate-mapping package="myPackage">
<class name="ServiceRequest" table="request" lazy="false">
<id name="id"><generator class="identity"/></id>
<many-to-one name="client" class="ServiceClient" column="client_id" cascade="none"/>
<many-to-one name="user" class="ServiceUser" column="user_id" cascade="none"/>
<many-to-one name="method" class="ServiceMethod" column="method_id" cascade="save-update"/>
</class>

When I use a ServiceRequest object to access the db via Hibernate, I get an error 'An association from the table request refers to an unmapped class: myPackage.ServiceMethod'. This makes perfect sense since I never called addClass() for ServiceMethod.

Is it possible for Hibernate to discover and load configuration files dynamically based on a single configuration file?

In this case, that would mean that I would call addClass( myPackage.ServiceRequest) and since that configuration file specifies the package name and class names, Hibernate would also addClass for the ServiceClient, ServiceUser, and ServiceMethod classes (finding their configuration files through the classpath).


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

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.