-->
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.  [ 4 posts ] 
Author Message
 Post subject: Abstract member question
PostPosted: Wed Jan 31, 2007 4:48 pm 
Newbie

Joined: Wed Jan 31, 2007 12:48 pm
Posts: 6
Hello,

I am new to JPA/Hibernate, so this might be a trivial question. Apologies upfront.

I am trying to persist a generic Value object either using generics or inheritance.

Using inheritance I have something like


Code:

@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
abstract class Value {
  @Id @GeneratedValue int id;
  abstract double getDouble();
  abstract int getInt();
  abstract String getStr();
}

@Entity
class DoubleValue extends Value {
  double dv;
...
}

@Entity
class StringValue extends Value {
  String sv;
...
}

I then try to use this in another class

@Entity(name="Pg1g")
public class Pg1G {
  @Id @GeneratedValue int id;
  Value v;
...






Unfortunately that does not work. I get

Quote:
Could not determine type for: pg.ejb3.Value, for columns: [org.hibernate.mapping.Column(v)]



I also tried to get this going with generics but that also failed.

So...what is the recommended approach to have something like the Value class from above as a member in another class (preferrable Embedded) and get that persisted?

Any advice or pointers warmly welcomed!

Peter

PS I am using

Hibernate version:
3.2.2

Name and version of the database you are using:
mySql 5


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 7:19 pm 
Newbie

Joined: Wed Jan 31, 2007 12:48 pm
Posts: 6
I guess I found the answer in the ejb3 spec.

On p23 I read

Quote:
2.1.5 Embeddable Classes
...
Because these objects have no persistent identity, they are typically mapped together
with the entity instance to which they belong.[10]
....

[10] Support for collections of embedded objects and for the polymorphism and inheritance of embeddable classes will be required in
a future release of this specification.


I guess I am out of luck here or are there other ways to model this?

Thanks,

Peter


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 7:48 pm 
Regular
Regular

Joined: Mon Nov 14, 2005 7:33 pm
Posts: 73
pc.subscriptions@gmail.co wrote:
I guess I found the answer in the ejb3 spec.

On p23 I read

Quote:
2.1.5 Embeddable Classes
...
Because these objects have no persistent identity, they are typically mapped together
with the entity instance to which they belong.[10]
....

[10] Support for collections of embedded objects and for the polymorphism and inheritance of embeddable classes will be required in
a future release of this specification.


I guess I am out of luck here or are there other ways to model this?

Thanks,

Peter


I guess I'm lost on your motivations for this, it seems more complicated then is usually necessary.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 7:56 pm 
Newbie

Joined: Wed Jan 31, 2007 12:48 pm
Posts: 6
Thanks for your reply.

I guess what I am trying to model is a class definition that has a member that is typed with an abstract class.

Peter


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