0 Replies Latest reply on Mar 4, 2008 8:37 AM by mars1412

    @Length not working on embedded component

    mars1412 Apprentice

      When I use @Length annotation on the fields of my entity, the column in the table is created with the expected length (see email field in the example below)

      But in embedded components, it seems that the @Length annotation is ignored (when creating the table) and the column in the table is always 255 characters long.
      If I also add the @Column(lenght=xx) annotation on the embedded string, it works as expected.

      • why is this different behavior?
      • what can I do about it?
      • or should I always use both annotations: @Length and @Column(lenght=xx)?

        @Table(appliesTo = "WEBUSER", indexes = { @Index(name = "IDX_WEBUSER_NAME_FIRSTNAME", columnNames = { "NAME", "FIRSTNAME" }) })
        @NamedQuery(name = "WebUser.getByEmail", query = "select u from WebUser u where u.email = :email")
        public class WebUser implements Serializable {
         private Long id;
         private String email;
         private Address address = new Address();
         @Id @GeneratedValue
         public Long getId() {
         return id;
         public String getEmail() {
         return email;
         public Address getAddress() {
         return address;

        public class Address implements Serializable {
         private String city;
         public String getCity() {
         return city;

        length of email field in the table: 100 (as expected)
        length of city field in table: 255 (30 expected)