-->
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.  [ 3 posts ] 
Author Message
 Post subject: Embeddable with collection of value objects, used twice
PostPosted: Mon Dec 18, 2006 10:22 am 
Newbie

Joined: Thu Jan 06, 2005 8:05 am
Posts: 13
Hello.

Can anyone tell me if this is possible at all using Hibernate Annotations?

I have an entity that has same embeddable object used twice, and this embeddable has collection of value objects, say List<String> for simplicity.

public class MyEntity {

private CatRegistry domesticCatRegistry;
private CatRegistry foreignCatRegistry;

}

@Embeddable
public class CatRegistry {

@CollectionOfElements
private List<String> names;

....
}

How can I specify mapping of this entity to end up having cat names stored in DOMESTIC_CAT_REGISTRY_NAMES table, and other CatRegistry instance names to be in FOREIGN_CAT_REGISTRY_NAMES?

Table for collection of elements is usually specified using :

@CollectionOfElements
@JoinTable(name = "CAT_REGISTRY_NAMES")

but since I have 2 instances of CatRegistry, I would need somehow to override table name which I cannot see if it's possible?

-Vjeran


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 18, 2006 11:38 am 
Beginner
Beginner

Joined: Sat Feb 18, 2006 6:24 am
Posts: 23
So, if I understood, you need different mapping for two instances of same class.
I don't think this is possible, it is not even logical, if you think it over.

OR mapping is based on class structures and relations between classes and class properties, not on instances and instance properties.

I don't think this is hibernate annotations problem, that kind of mapping isn't possible in Hibernate at all. Somebody correct me if I 'm wrong.

So, I think that only solution for situation you have is to define two different classes for each value object. Something like this:

Code:
public class MyEntity {

private DomesticCatRegistry domesticCatRegistry;
private ForeignCatRegistry foreignCatRegistry;

}

@Embeddable
public class DomesticCatRegistry {

@CollectionOfElements
private List<String> names;

....
}

@Embeddable
public class ForeignCatRegistry {

@CollectionOfElements
private List<String> names;

....
}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 18, 2006 1:43 pm 
Newbie

Joined: Thu Jan 06, 2005 8:05 am
Posts: 13
I reformulated my question better, and it is gien in new post at: http://forum.hibernate.org/viewtopic.php?t=968791


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