-->
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.  [ 2 posts ] 
Author Message
 Post subject: Embedded Generic
PostPosted: Mon Jul 31, 2006 11:19 am 
Newbie

Joined: Mon Jul 31, 2006 10:57 am
Posts: 8
Hi,

I'm using Hibernate annotations and I'm trying to make en embedded generic class persistent

@Embeddable
class Manager<T extends PersistentObject> {

@OneToMany(cascade = CascadeType.All, targetEntity=PersistentObject.class)
List<T> objects = new ArrayList<T>();


//Getter und Setter
....

}

Another class uses this Manager class for different persistentObject subclasses

@Entity
class Person extends PersistentObject {

@Embedded
Manager<PhoneNumber> phoneNumberManager = new Manager<PhoneNumber>();

@Embedded
Manager<Address> addressManager = new Manager<Address>();

//Getter und Setter
......
}

@Entity
class Address extends PersistentObject {
....
}

@Entity
class Phonenumber extends PersistentObject {
...
}

Everything works without an error, but the problem is that I have just one
JoinTable called person_persistentobject.

Is it possible to get a different JoinTables for every Generic like person_address, person_phonenumber.....?

Thanks for help!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 3:37 am 
Newbie

Joined: Mon Jul 31, 2006 10:57 am
Posts: 8
I guess, I have solved the problem.

I'm using the
@AccessType(value = "property")
annotation for the person now. That means that now I annotate the getter and setter not the fields.

@OneToMany(cascade = CascadeType.ALL)
public List<Address> getAddresses() {
return this.addressManager.getObjects();
}

Person intern everything is stored in the manager classes and hibernate gets it as generic lists


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