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: @Embedded: exclude column for embedded entity
PostPosted: Fri Jun 26, 2009 9:45 am 
Beginner
Beginner

Joined: Mon Nov 13, 2006 8:22 am
Posts: 28
hi,

I have an an Embeddable class Address which should be embedded into Customer.
Address contains the property type and this property I do not want to embed in the table CUSTOMER.

Is this possible and if so, how?

many thanks,
Stijn


Top
 Profile  
 
 Post subject: Re: @Embedded: exclude column for embedded entity
PostPosted: Fri Jun 26, 2009 2:37 pm 
Newbie

Joined: Tue Jun 03, 2008 3:49 pm
Posts: 6
Location: Dominican Republic
Hi, have you tried using @Transient annotation on that field/getter?


Top
 Profile  
 
 Post subject: Re: @Embedded: exclude column for embedded entity
PostPosted: Fri Jun 26, 2009 2:52 pm 
Beginner
Beginner

Joined: Mon Nov 13, 2006 8:22 am
Posts: 28
forzaken wrote:
Hi, have you tried using @Transient annotation on that field/getter?


Thanks for the suggestion.

I probably should have mentioned that Address is also used as 'stand-alone' entity and in this context 'type' is required.
I can hardly imagine it is not possible to only embed some properties of an embeddable entity.

thanks,
Stijn


Top
 Profile  
 
 Post subject: Re: @Embedded: exclude column for embedded entity
PostPosted: Wed Jul 01, 2009 8:55 am 
Beginner
Beginner

Joined: Mon Nov 13, 2006 8:22 am
Posts: 28
All,

found a solution myself:

split up Address in 2 classes:
Code:
@Embeddable
@MappedSuperclass
public class EmbeddableAddress extends AbstractEntity {

    private String street;

    private String number;

    private String box;


and simply Address which contains the properties you do not want to be embeddable:
Code:
@Entity
@Table(name = "ADDRESS")
public class Address extends EmbeddableAddress {

    private AddressType addressType;

    private Long id;


tried it and works great.

regards,
Stijn


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.