-->
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.  [ 1 post ] 
Author Message
 Post subject: CompositeUserType in repeated @Embeddable => repeated column
PostPosted: Tue Jul 21, 2009 11:51 am 
Newbie

Joined: Mon May 25, 2009 11:39 am
Posts: 2
Hello,

I have made a CompositeUserType (NumberHelper) that consists of two fields (big decimal "value" and string "type"). It works as expected, except when I use it inside an @Embeddable type that is then used more than once inside an entity.

Code:
@Embeddable
public class Benefit implements Serializable {
(...)
   // Interval
   @Columns(columns = { @Column(name = "intv_from_value"), @Column(name = "intv_from_type") })
   @Type(type = "NumberHelper")
   NumberValueHelper intv_from;

   @Columns(columns = { @Column(name = "intv_to_value"), @Column(name = "intv_to_type") })
   @Type(type = "NumberHelper")
   NumberValueHelper intv_to;
(...)
}

Code:
@Entity
@TypeDef(name = "NumberHelper", typeClass = NumberHelperUserType.class)
public class Coverage {
(...)
   @AttributeOverrides( {
         @AttributeOverride(name = "intv_from_type", column = @Column(name = "type_a_intv_from_type")),
         @AttributeOverride(name = "intv_from_value", column = @Column(name = "type_a_intv_from_value")),
         @AttributeOverride(name = "intv_to_type", column = @Column(name = "type_a_intv_to_type")),
         @AttributeOverride(name = "intv_to_value", column = @Column(name = "type_a_intv_to_value")) })
   private Benefit benefitTypeA;

   @AttributeOverrides( {
         @AttributeOverride(name = "intv_from_type", column = @Column(name = "type_b_intv_from_type")),
         @AttributeOverride(name = "intv_from_value", column = @Column(name = "type_b_intv_from_value")),
         @AttributeOverride(name = "intv_to_type", column = @Column(name = "type_b_intv_to_type")),
         @AttributeOverride(name = "intv_to_value", column = @Column(name = "type_b_intv_to_value")) })
   private Benefit benefitTypeB;
(...)
}

When I run this, I get:
Quote:
(...)
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: com...Coverage column: intv_from_value (should be mapped with insert="false" update="false")

I.e. the AttributeOverride isn't applied to column-names inside the @Columns(...) annotation.

This is confirmed by removing one of the "Benefit" fields in "Coverage", in which case it works fine, but the fields are named "intv_*", not "type_a_intv_*" as expected.

Is this a bug or expected? Is there a workaround for this behaviour?

Regards,
Martin


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.