-->
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: reveng.xml - how to change set to lazy="false"
PostPosted: Thu Apr 01, 2010 9:18 am 
Beginner
Beginner

Joined: Thu Mar 27, 2008 8:49 am
Posts: 27
I am really struggling with reveng.xml now that the documentation seems to have vanished. I did have this page bookmarked which I found quite useful but now it is a 404.

My problem is that I am using auto-generation of both source and hbm.xml files and one of my hbm.xml files has the following:

Code:
<set name="HTActivities" inverse="false" lazy="true" table="htDayEntryToActivity" fetch="select">
    <key>
        <column name="day_entry_id" not-null="true" />
    </key>
    <many-to-many entity-name="uk.co.prodia.prosoc.domainmodel.HTActivity">
        <column name="activity_id" not-null="true" />
    </many-to-many>
</set>


I would like to change that using the reveng.xml file so that it has:

Code:
lazy="false"


The table htDayEntryToActivity is a simple join table that holds the two primary keys between htDayEntry and htActivity. I assume I need something like:

Code:
<table name="htDayEntryToActivity" catalog="habittracker">
    <foreign-key constraint-name="fk_htDayEntryToActivity_activity_id">
        <set lazy="false"/>
    </foreign-key>
</table>


but that does not work as it throws a parse error:

Quote:
Attribute "lazy" must be declared for element type "set".


Can anyone provide a sample code snippet that would do that? If anyone has a link to the documentation that would also be very handy!


Top
 Profile  
 
 Post subject: Re: reveng.xml - how to change set to lazy="false"
PostPosted: Thu Apr 01, 2010 9:28 am 
Regular
Regular

Joined: Wed Mar 10, 2010 4:48 am
Posts: 106
use lazy="no-proxy"


Top
 Profile  
 
 Post subject: Re: reveng.xml - how to change set to lazy="false"
PostPosted: Thu Apr 01, 2010 10:09 am 
Beginner
Beginner

Joined: Thu Mar 27, 2008 8:49 am
Posts: 27
Thanks for the reply but it didn't work as I am encountering the error before it get to read that attribute. I am using:

Code:
<table name="htDayEntryToActivity" catalog="habittracker">
    <foreign-key constraint-name="fk_htDayEntryToActivity_activity_id">
        <set lazy="no-proxy"/>
    </foreign-key>
</table>


and it is complaining about:

Quote:
org.hibernate.MappingException: invalid override definition
org.xml.sax.SAXParseException: Attribute "lazy" must be declared for element type "set".
org.hibernate.MappingException: Could not configure overrides from file: /storage/gavin/work/mercurial/habittracker/prosoc/database/hibernate.reveng.prosoc.xml
at org.hibernate.cfg.reveng.OverrideRepository.addFile(OverrideRepository.java:119)
at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:63)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:318)
at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:94)
at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor52.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:278)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:498)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
Caused by: org.hibernate.MappingException: invalid override definition


I assume it means that the attribute lazy is not a part of the hibernate-reverse-engineering-3.0.dtd DTD for the element set.


Top
 Profile  
 
 Post subject: Re: reveng.xml - how to change set to lazy="false"
PostPosted: Thu Apr 01, 2010 10:20 am 
Regular
Regular

Joined: Wed Mar 10, 2010 4:48 am
Posts: 106
Try this:

Code:
<class name="A">
   <set name="setNameA" table="name_of_the_join-table">
      <key column="FK_to_A" />
      <many-to-many class="class_B" column="FK_to_B" />
   </set>
</class>

<class name="B">
   <set name="setNameB" table="name_of_the_join-table" inverse="true">// note the inverse, one of the two needs this
      <key column="FK_to_B" />
      <many-to-many class="class_A" column="FK_to_A" />
   </set>
</class>

This will create a join-table between A and B, which will have a foreign key to A and a foreign key to B.
And you should be able to add lazy="false" to this sets.


Top
 Profile  
 
 Post subject: Re: reveng.xml - how to change set to lazy="false"
PostPosted: Thu Apr 01, 2010 10:39 am 
Beginner
Beginner

Joined: Thu Mar 27, 2008 8:49 am
Posts: 27
That looks like an excellent reply but I think I may have something else wrong. I am getting the error:

Quote:
org.xml.sax.SAXParseException: Element type "class" must be declared.


This happens a lot but I have successfully used:

Code:
<foreign-key constraint-name="fk_htUserTrackerDataMapper_tracker_id">
    <set cascade="persist,merge,save-update" />
</foreign-key>


in several places in the reveng.xml file so I know that it is essentially set up correctly. For some reason it doesn't notice many of the elements I have tried such as <class /> , <many-to-many /> etc. I had just assumed that they were not part of the DTD.


Top
 Profile  
 
 Post subject: Re: reveng.xml - how to change set to lazy="false"
PostPosted: Thu Apr 01, 2010 10:50 am 
Regular
Regular

Joined: Wed Mar 10, 2010 4:48 am
Posts: 106
Here's a template:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
   <class name="class" table="table_name">
      // add the id, properties and sets here
   </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: Re: reveng.xml - how to change set to lazy="false"
PostPosted: Thu Apr 01, 2010 10:59 am 
Beginner
Beginner

Joined: Thu Mar 27, 2008 8:49 am
Posts: 27
I am afraid the code you are providing is for the hbm.xml files which I am auto-generating. In order to control the auto-generated hbm.xml files then a reveng.xml file is used. It is the syntax over that file that I am having trouble with. For some reason it is significantly different to a standard hbm.xml file and since the documentation is no longer available it is making things extremely difficult.


Top
 Profile  
 
 Post subject: Re: reveng.xml - how to change set to lazy="false"
PostPosted: Thu Apr 01, 2010 11:14 am 
Regular
Regular

Joined: Wed Mar 10, 2010 4:48 am
Posts: 106
klogger wrote:
In order to control the auto-generated hbm.xml files then a reveng.xml file is used.


I don't really understand you, but if auto-generating doesn't work you could try it manually.


Top
 Profile  
 
 Post subject: Re: reveng.xml - how to change set to lazy="false"
PostPosted: Thu Apr 01, 2010 11:21 am 
Beginner
Beginner

Joined: Thu Mar 27, 2008 8:49 am
Posts: 27
I am too far into the project to unwind and rebuild but thanks for your help. Next time I think I will not use Hibernate Tools as they are causing far more trouble than they are worth.

If anyone else has any ideas then they would be most welcome as I am probably going to need to manually retrieve the objects I need and add then to the hibernate result. I was using Hibernate in the first place to avoid all of that!


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.