-->
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: Inserting an object containing non-persisted objects
PostPosted: Thu Feb 05, 2009 5:42 pm 
Beginner
Beginner

Joined: Thu Jan 29, 2009 1:24 am
Posts: 20
Hello all,

I have the following standard bean objects as follows:

Code:
class A implements Serializable {
  private Long id;
  private Point point;
  private String name;
  ...
}

class Point implements Serializable {
  private int x;
  private int y;
  ...
}


Class A is marked as an entity for persisting to the database. Class Point is not marked as an entity since it is a simple data object. Point's are always specific to all class A objects so it doesn't make sense to create a table mapping one to one. The generated database schema creates the point field in class A's table as a blob.

My problem is whenever I try and push an object of class A into the database which contains a Point object I get an insert error with hibernate. So how do I get hibernate to save my object?

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2009 5:50 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
What you are looking for is a Hibernate feature called "components". You can find more information in the Hibernate docs. http://www.hibernate.org/hib_docs/v3/re ... nents.html


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2009 6:32 pm 
Beginner
Beginner

Joined: Thu Jan 29, 2009 1:24 am
Posts: 20
That's definitely what I want. All of my objects are defined using JPA instead of hibernate XML. Is there a JPA equivalent to this? I can't seem to find it on google.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2009 6:41 pm 
Beginner
Beginner

Joined: Thu Jan 29, 2009 1:24 am
Posts: 20
caskater4 wrote:
That's definitely what I want. All of my objects are defined using JPA instead of hibernate XML. Is there a JPA equivalent to this? I can't seem to find it on google.


Found what I want. Thanks for the help.

http://www.hibernate.org/hib_docs/annot ... le/#d0e569


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.