-->
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.  [ 7 posts ] 
Author Message
 Post subject: Question about the hibernate-mapping-3.0.dtd and JAXB?
PostPosted: Tue May 19, 2009 4:04 pm 
Regular
Regular

Joined: Tue Jul 29, 2008 4:15 pm
Posts: 62
Location: Dallas, TX US
I am trying to use JAXB to auto-generated the elements defined in the hibernate-mapping-3.0.dtd file; but I get the following error:
Code:
5/19/09 2:50:23 PM GMT-05:00: [ERROR] XJC while parsing schema(s) file:/C:/Dev/aviall_jedi_workspace/hibernate-tools-ext/src/main/resources/hibernate-dtd/hibernate-mapping-3.0.dtd[382]: com.sun.istack.SAXParseException2: Property "Formula" is already defined. Use <jaxb:property> to resolve this conflict.
5/19/09 2:50:23 PM GMT-05:00: [ERROR] XJC while parsing schema(s) file:/C:/Dev/aviall_jedi_workspace/hibernate-tools-ext/src/main/resources/hibernate-dtd/hibernate-mapping-3.0.dtd[732]: com.sun.istack.SAXParseException2: Property "Type" is already defined. Use <jaxb:property> to resolve this conflict.


I am able to auto-generate the hibernate-mappings.dtd file successfully. The only difference between these two files that causes these errors are the following:
hibernate-mapping-3.0.dtd:
Code:
<!ELEMENT one-to-one (meta*,formula*)>
vs hibernate-mapping.dtd:
Code:
<!ELEMENT one-to-one (meta*|formula*)>

And hibernate-mapping-3.0.dtd:
Code:
<!ELEMENT element ( (column|formula)*, type? )>
vs hibernate-mapping.dtd:
Code:
<!ELEMENT element (column|formula)*>



Its seems there is a problem when specifying both children elements "formula" and "type". But when specifying either or via the "Or" operator, all works fine.

You can download a example JAXB2 project at https://maven-jaxb2-plugin.dev.java.net/docs/guide.html. Look for a link called, "See the sample JAXB2 plugins project for example.".

Any suggestion is much appreciated!

Thanks!

_________________
pouncilt


Top
 Profile  
 
 Post subject: Re: Question about the hibernate-mapping-3.0.dtd and JAXB?
PostPosted: Tue May 19, 2009 4:57 pm 
Regular
Regular

Joined: Tue Jul 29, 2008 4:15 pm
Posts: 62
Location: Dallas, TX US
Ok after further investigation, I have narrowed it down to the following snippets of xml in the hiberante-mapping-3.0.dtd:
Code:
<!ELEMENT element ( (column|formula)*, type? )>
   <!ATTLIST element column CDATA #IMPLIED>
   <!ATTLIST element node CDATA #IMPLIED>
   <!ATTLIST element formula CDATA #IMPLIED>
   <!ATTLIST element type CDATA #IMPLIED>
   <!ATTLIST element length CDATA #IMPLIED>
   <!ATTLIST element precision CDATA #IMPLIED>
   <!ATTLIST element scale CDATA #IMPLIED>
   <!ATTLIST element not-null (true|false) "false">
   <!ATTLIST element unique (true|false) "false">

Code:
<!ELEMENT one-to-one (meta*,formula*)>
   <!ATTLIST one-to-one name CDATA #REQUIRED>
   <!ATTLIST one-to-one formula CDATA #IMPLIED>
   <!ATTLIST one-to-one access CDATA #IMPLIED>
   <!ATTLIST one-to-one class CDATA #IMPLIED>
   <!ATTLIST one-to-one entity-name CDATA #IMPLIED>
   <!ATTLIST one-to-one cascade CDATA #IMPLIED>
   <!ATTLIST one-to-one outer-join (true|false|auto) #IMPLIED>
   <!ATTLIST one-to-one fetch (join|select) #IMPLIED>
   <!ATTLIST one-to-one constrained (true|false) "false">
   <!ATTLIST one-to-one foreign-key CDATA #IMPLIED>
   <!ATTLIST one-to-one property-ref CDATA #IMPLIED>
   <!ATTLIST one-to-one lazy (false|proxy|no-proxy) #IMPLIED>
   <!ATTLIST one-to-one node CDATA #IMPLIED>
   <!ATTLIST one-to-one embed-xml (true|false) "true">


I believe the above xml snippets is why a I am getting the aforementioned errors.

Is this a bug in the hibernate-mapping-3.0.dtd file?
Is there anybody out there that can help me with this issue?

_________________
pouncilt


Top
 Profile  
 
 Post subject: Re: Question about the hibernate-mapping-3.0.dtd and JAXB?
PostPosted: Fri May 22, 2009 2:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I'm not sure what you are asking about.

You refer to both hibernate-mapping-3.0.DTD and hibernate-mapping.DTD - which one is it ?

And why is it a bug in the DTD that jaxb can't generate mappings for it ? The DTD is valid, are you
sure it isn't jaxb that are problematic ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Question about the hibernate-mapping-3.0.dtd and JAXB?
PostPosted: Fri May 22, 2009 11:04 am 
Regular
Regular

Joined: Tue Jul 29, 2008 4:15 pm
Posts: 62
Location: Dallas, TX US
I referred to both of the DTDs to show how they differ in regards to the formula and type children elements. If you do a quick compare of the two DTDs, you will find that these two children elements are always used with an "OR" operator in hibernate-mapping.dtd. In the hibernate-mapping-3.0.dtd these two children elements are always used with an "OR" operator, except for lines 380 and 728. Which brings me to the question is there a typo or an over site in the hibernate-mapping-3.0.dtd file at the lines 380 and 728? Should these two lines use a "OR" operator like so on line 728 of hibernate-mapping-3.0.dtd file:
Code:
<!ELEMENT element ( (column|formula)*| type? )>
instead of what is actually there; which is
Code:
<!ELEMENT element ( (column|formula)*, type? )>
. And on line 380 of hibernate-mapping-3.0.dtd file:
Code:
<!ELEMENT one-to-one (meta*|formula*)>
instead of what is actually there; which is
Code:
<!ELEMENT one-to-one (meta*,formula*)>


I am able to use JAXB to generate the java objects for hibernate-mapping.dtd, because it uses the "OR" operator for the formula and type children elements. However because of how the hibernate-mapping-3.0.dtd file does NOT use the "OR" operator, as described above; I am not able to generate the java objects via JAXB.

I understand that the hibernate-mapping-3.0.dtd is syntactically valid; but I want to know is it logically correct in not using the "OR" operator as described above? If you say it is logically correct, then I will look for an alternative solution. One alternative solution would be to just change my local copy of the hibernate-mapping-3.0.dtd to use the "OR" operators as described above. If I opt for this solution, do you see anything wrong with that? Another solution is to work with JAXB and its custom binding features to solve the original error. Either one of these works for me, but I didn't want to start changing stuff without first understanding the root problem.

Thanks!

_________________
pouncilt


Top
 Profile  
 
 Post subject: Re: Question about the hibernate-mapping-3.0.dtd and JAXB?
PostPosted: Sat May 23, 2009 4:37 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
pouncilt wrote:
Should these two lines use a "OR" operator like so on line 728 of hibernate-mapping-3.0.dtd file:
Code:
<!ELEMENT element ( (column|formula)*| type? )>
instead of what is actually there; which is
Code:
<!ELEMENT element ( (column|formula)*, type? )>
.


No, first you want a sequence of column and formula with an optional last type element. The current one is correct.

Quote:
And on line 380 of hibernate-mapping-3.0.dtd file:
Code:
<!ELEMENT one-to-one (meta*|formula*)>
instead of what is actually there; which is
Code:
<!ELEMENT one-to-one (meta*,formula*)>


No, since that would prevent users from specifying formula's which is what they need to do.

Quote:
I understand that the hibernate-mapping-3.0.dtd is syntactically valid; but I want to know is it logically correct in not using the "OR" operator as described above? If you say it is logically correct, then I will look for an alternative solution.


It is semantically correct what is in the DTD.

May I ask why you want to JAXB hibernate mappings ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Question about the hibernate-mapping-3.0.dtd and JAXB?
PostPosted: Tue Jan 08, 2013 10:51 am 
Newbie

Joined: Wed Jun 20, 2012 4:55 pm
Posts: 7
I'm curious which approach you took to solve this problem. I am also looking to generate java files from the hibernate 3.0 dtd and encounter this error.

The reason I am trying to do it is because we have a very large hbm.xml (around 180 class elements) and we are in the process of converting these definitions to JPA annotated classes. One way I thought I could do this was to write a custom script to parse each class element in the hbm.xml to generate a rough outline for the JPA annotated class (I'm not expecting perfection, but something to eliminate the bulk of the grunt work).

Anther suggestion that I found on the web was to use Hibernate's SchemaExport tool and then the Hibernate Pojo Generator that generates Hibernate annotated classes from the DB schema. From what I can tell though it looks like the Hibernate Pojo Generator is limited to a MySql dialect and I need to use an Oracle dialect (difference being the support of ID vs. Sequence support).

Anyways, were you ever able to generate Java classes from the hibernate-mapping-3.0.dtd using JAXB?


Top
 Profile  
 
 Post subject: Re: Question about the hibernate-mapping-3.0.dtd and JAXB?
PostPosted: Tue Jan 08, 2013 6:00 pm 
Newbie

Joined: Wed Jun 20, 2012 4:55 pm
Posts: 7
I found an alternate solution to my specific problem. JBoss has a Hibernate-tools Eclipse plugin which includes an hbm2java tool. This tool can be configured to generate EJB3 (JPA) annotated classes from hbm.xml files and is good enough for the purposes I am looking for.


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