[hibernate-issues] [Hibernate-JIRA] Created: (HHH-5937) @Enumerated(EnumType.STRING) not taken into account in an @Embeddable included in another @Embeddable

Thomas Vanstals (JIRA) noreply at atlassian.com
Fri Feb 18 05:59:05 EST 2011


@Enumerated(EnumType.STRING) not taken into account in an @Embeddable included in another @Embeddable
-----------------------------------------------------------------------------------------------------

                 Key: HHH-5937
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5937
             Project: Hibernate Core
          Issue Type: Bug
          Components: annotations
    Affects Versions: 3.6.1
         Environment: MySQL 5.1.40 / hibernate-entitymanager 3.6.1.Final
            Reporter: Thomas Vanstals


I have a Customer entity containing a collection of Investment. 
The Investment ({{@Embeddable}}) class contains a MonetaryAmount.
The MonetaryAmount ({{@Embeddable}}) contains an enumerated property ('currency') annotated with {{@Enumerated(EnumType.STRING)}}.
The 'currency' field is mapped to a column having the following definition: {{`currency` int(11) DEFAULT NULL}}. This is not correct. The column definition should be {{`currency` varchar(3) DEFAULT NULL}}.

If a add a MonetaryAmount property in the Customer class, the generated column definition is correct ({{`currency` varchar(3) DEFAULT NULL}}).

{code:title=Customer.java|borderStyle=solid}
@Entity
public class Customer {

  @Valid
  @ElementCollection(fetch = FetchType.EAGER)
  private List<Investment> investments = new ArrayList<Investment>();

}
{code}

{code:title=Investment.java|borderStyle=solid}
@Embeddable
public class Investment {
	
  @Valid @NotNull
  private MonetaryAmount amount;
	
  @Column(length = 500) @Length(max = 500)
  private String description;
	
  private Date date; 
	
}
{code}

{code:title=MonetaryAmount.java|borderStyle=solid}
@Embeddable
public class MonetaryAmount {

  @NotNull
  private Double amount;

  @Column(length = 3)
  @Enumerated(EnumType.STRING)
  private CurrencyCode currency;

}
{code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list