-->
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: No entity-name attribute in <key-many-to-one> element?
PostPosted: Mon Jan 31, 2005 1:13 pm 
Newbie

Joined: Mon Jan 31, 2005 12:11 pm
Posts: 3
Hibernate version:
3.0 Beta 2

The entity-name attribute has been working quite well so far to enable a refactoring of my domain model to consolidate several nearly identical classes that were mapped to different tables down to one class, but now I've hit a snag.

I'm trying to map a child entity with a natural primary key using the composite-id element. Its parent entity is one of the refactored classes I've created using the entity-name attribute to map it to multiple tables. One of the properties that makes up the composite id of the child is also the foreign key that relates it to the parent entity.

I had hoped to use a mapping such as:

Code:
<composite-id>
    <key-many-to-one name="parent"
                                column="parentId" 
                                entity-name="parentEntity1"/>
    <key-property name="lineNum"
                          column="Line_Number"/>
</composite-id>


but entity-name is not a valid attribute of the <key-many-to-one> element according to the DTD.

Is this something that could be added, or is there an alternate way I should be going about the mapping?

Thanks,
Jeremy


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 03, 2005 9:55 am 
Newbie

Joined: Mon Jan 31, 2005 12:11 pm
Posts: 3
I modified the DTD in my hibernate3.jar to have entity-name as an attribute of the <key-many-to-one> element. Hibernate seems to have handled the mapping with no adverse effects.

Can this change be made to the DTD going forward, or is there a specific reason it was left out? It seems like it would be consistent with the use of entity-name in the various other relationship mappings.

For the sake of thoroughness, here is the modified section of the DTD with entity-name added:
Code:
<!ELEMENT key-many-to-one (meta*,column*)>
   <!ATTLIST key-many-to-one name CDATA #REQUIRED>
   <!ATTLIST key-many-to-one access CDATA #IMPLIED>
   <!ATTLIST key-many-to-one class CDATA #IMPLIED>
   <!ATTLIST key-many-to-one entity-name CDATA #IMPLIED>
   <!ATTLIST key-many-to-one column CDATA #IMPLIED>
   <!ATTLIST key-many-to-one foreign-key CDATA #IMPLIED>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 03, 2005 10:29 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
sounds like a bug in the DTD.

please submit it to the jira with a patch. thank you.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: What about <map-key-many-to-many> and <index-many-t
PostPosted: Fri Feb 04, 2005 2:44 pm 
Newbie

Joined: Mon Jan 31, 2005 12:11 pm
Posts: 3
I went to pull the source and create a patch this morning, but it seems that the above change has already been committed.

I then thought to check for other places that entity-name might be missing from the DTD and came up with <map-key-many-to-many> and <index-many-to-many>. Again it seems that for consistency, these too should allow relating to an entity-name. So the effected sections of the DTD would look something like this:

Code:
<!ELEMENT map-key-many-to-many (column*)>
   <!ATTLIST map-key-many-to-many class CDATA #IMPLIED>
   <!ATTLIST map-key-many-to-many entity-name CDATA #IMPLIED>
   <!ATTLIST map-key-many-to-many column CDATA #IMPLIED>
   <!ATTLIST map-key-many-to-many foreign-key CDATA #IMPLIED>

<!ELEMENT index-many-to-many (column*)>
   <!ATTLIST index-many-to-many class CDATA #IMPLIED>
   <!ATTLIST index-many-to-many entity-name CDATA #IMPLIED>
   <!ATTLIST index-many-to-many column CDATA #IMPLIED>
   <!ATTLIST index-many-to-many foreign-key CDATA #IMPLIED>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 04, 2005 4:23 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
put it in the jira if something is still missing

_________________
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.