-->
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.  [ 5 posts ] 
Author Message
 Post subject: Error while trying reverse-engineering
PostPosted: Tue Jun 22, 2010 10:33 am 
Newbie

Joined: Mon Jun 21, 2010 2:09 pm
Posts: 1
Hi,

Any help here would be greatly appreciated. I am trying to reverse-engineer, using hbm2hbmxml, a postgres database using Maven Hibernate 3 plugin or Ant's Hibernate tool and getting the following error:


Caused by: org.xml.sax.SAXParseException: Attribute "cascade" must be declared for element type "many-to-one".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.reveng.OverrideRepository.addInputStream(OverrideRepository.java:142)
... 25 more

The culprid is my hibernate.reveng.xml file when I try to define a cascade. below is a copy of my hibernate.reveng.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >

<hibernate-reverse-engineering>

<schema-selection match-schema="" match-table="abc_.*" />

<table schema="public" name="abc_customer" class="abc.Customer">
<primary-key>
<generator class="abc.sequence.CustomerSequence">
<param name="sequence">Customer Sequence</param>
<param name="parameters">start with 5000000 increment by 1 cache 20</param>
</generator>
<key-column name="customer_id" property="key"/>
</primary-key>

<foreign-key constraint-name="phone1" foreign-table="abc_phone">
<column-ref local-column="phone1_id" foreign-column="phone_id"/>
<many-to-one property="phone1" exclude="false" cascade="save-update" />
</foreign-key>
</table>

</hibernate-reverse-engineering>



Below here is a copy of what jar versions are being used:

1. hibernate/ejb3-persistence - 1.0.2.GA
2. hibernate/hibernate-annotations - 3.4.0.GA
3. hibernate/hibernate-commons-annotations - 3.1.0.GA
4. hibernate/hibernate-core - 3.1.0.GA
5. hibernate/hibernate-entitymanager - 3.4.0.GA
6. hibernate/hibernate-parent - 3.3.1.GA
7. hibernate/hibernate-tools - 3.2.3.GA
8. hibernate/jtidy - 48-20060801


I read in that there was fixe in a prior release (http://opensource.atlassian.com/project ... issue-tabs), but appears that the current DTD file does not support this.

Thank you for your help,

R


Top
 Profile  
 
 Post subject: Re: Error while trying reverse-engineering
PostPosted: Tue Jan 18, 2011 4:08 pm 
Newbie

Joined: Tue Jan 18, 2011 3:31 pm
Posts: 4
I checked the DTD and it is not up to date.

http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd

The version packaged with JBoss Tools 3.1 is a newer version with the cascade update.

I have installed the jboss version to my eclipse IDE and I am trying to implement cascade attribute using reverse engineering but it doesn't seem to be working.

Please assist.


Top
 Profile  
 
 Post subject: Re: Error while trying reverse-engineering
PostPosted: Fri Jan 21, 2011 9:47 am 
Newbie

Joined: Tue Jan 18, 2011 3:31 pm
Posts: 4
Thanks for your reply.

I had a look at the Test class and I can see that the HibernateMappingGlobalSettings does cater for cascade and lazy but the eclipse code gen Exporter task does not generate the cascade attribute in the parent table set element.

Am i missing something?

Here is snippet of my reveng file and the file it generates

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering SYSTEM "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd">
<hibernate-reverse-engineering>

   <table-filter match-name="SCRIPT" package="package" />
   <table-filter match-name="SCRIPT_TRCK_STATE" package="package" />

   <table schema="DMX" name="SCRIPT" class="Script">
      <primary-key>
         <generator class="sequence">
            <param name="sequence">SCRIPT_SEQ</param>
         </generator>
         <key-column name="SCRIPT_ID" type="long" />
      </primary-key>
   </table>

   <table schema="DMX" name="SCRIPT_TRCK_STATE" class="ScriptTrackingState" >
      <primary-key>
         <generator class="sequence">
            <param name="sequence">GENERIC_SEQ</param>
         </generator>
         <key-column name="SCRIPT_TRACKING_ID" />
      </primary-key>   
      <column name="STATE_CHANGE_DATE" property="stateChangeDate" type="timestamp" />
      <foreign-key constraint-name="FK" foreign-table="SCRIPT">
         <column-ref local-column="SCRIPT_ID" foreign-column="SCRIPT_ID" />
         <many-to-one property="scriptId" cascade="save-update" />
      </foreign-key>
   </table>
</hibernate-reverse-engineering>


Generates the following Script.hbm.xml mapping

Code:
<hibernate-mapping>
    <class name="package.Script" table="SCRIPT" schema="DMX">
        <id name="scriptId" type="long">
            <column name="SCRIPT_ID" precision="15" scale="0" />
            <generator class="sequence">
                <param name="sequence">SCRIPT_SEQ</param>
            </generator>
        </id>
        <set name="scriptTrackingStates" inverse="true" lazy="true" table="SCRIPT_TRCK_STATE" fetch="select">
            <key>
                <column name="SCRIPT_ID" precision="15" scale="0" not-null="true" />
            </key>
            <one-to-many class="package.ScriptTrackingState" />
        </set>
        <set name="scriptTrackingStates_1" inverse="true" lazy="true" table="SCRIPT_TRCK_STATE" fetch="select">
            <key>
                <column name="SCRIPT_ID" precision="15" scale="0" not-null="true" />
            </key>
            <one-to-many class="package.ScriptTrackingState" />
        </set>
    </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject: Re: Error while trying reverse-engineering
PostPosted: Sat Jan 22, 2011 1:10 am 
Newbie

Joined: Tue Jan 18, 2011 3:31 pm
Posts: 4
I am not sure I follow. Is the Exporter not supposed to do that for you using the reveng config ?

Are you saying that the only way to apply cascade on reverse engineer is to do it programatically as with the Hbm2HbmXmlTest?


Top
 Profile  
 
 Post subject: Re: Error while trying reverse-engineering
PostPosted: Mon Jan 31, 2011 4:17 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
jeremy4j wrote:
I am not sure I follow. Is the Exporter not supposed to do that for you using the reveng config ?

Are you saying that the only way to apply cascade on reverse engineer is to do it programatically as with the Hbm2HbmXmlTest?


No no - reveng.xml has support for cascade attributes on set, and the *-to-one's.

You can see that used in the unit test code which has src/test/org/hibernate/tool/test/jdbc2cfg/foreignkeytest.reveng.xml which has xml like this:
Code:
  <table name="PROJECT">
            <foreign-key constraint-name="PROJECT_MANAGER">
                <many-to-one exclude="true"/>
                <set property="managedProjects" cascade="delete, update"/>
            </foreign-key>
        </table> 

_________________
Max
Don't forget to rate


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