-->
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: Defining the length of the column
PostPosted: Sat Nov 11, 2006 1:54 am 
Newbie

Joined: Sat Nov 11, 2006 1:27 am
Posts: 1
Hibernate version:3.0

Name and version of the database you are using:HSQL


Problem: I have used hibernate annotations in my class...........But even after specifying the column length annotation its taking the default value(255)............

For example I have defined the value of contact number field in the class below as 15.......But even when i try to insert more than that it isn't showing any errors and persisting it in db...........Is there any problem with my @Column(length = 15) syntax.........


Here is the code for one of my class......


Code:
package incture.model.businessobject;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.Proxy;

@SuppressWarnings("serial")
@Entity
@Proxy(lazy = false)
@Table(name = "doctorDetails", uniqueConstraints = { @UniqueConstraint(columnNames = { "doctorname" }) })
@javax.persistence.SequenceGenerator(name = "seq_gen_doc", sequenceName = "seq_doctor", initialValue = 100)
public class DoctorDo extends BaseDo implements Serializable {

    // @Id @GeneratedValue(strategy=GenerationType.AUTO)
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seq_gen_doc")
    @Column(length = 10)
    private Long doctorId;

    @Column(nullable = false, length = 50)
    private String doctorname;

    @Column(length = 30)
    private String department;

    @Column(length = 50)
    private String address;

    @Column(length = 30)
    private String city;

    @Column(length = 20)
    private String country;

    @Column(length = 10)
    private String zipcode;

    @Column(length = 15)
    private String contactNumber;

    @Column(length = 50)
    private String email;

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getContactNumber() {
        return contactNumber;
    }

    public void setContactNumber(String contactNumber) {
        this.contactNumber = contactNumber;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getDepartment() {
        return department;
    }

    public void setDepartment(String department) {
        this.department = department;
    }

    public Long getDoctorId() {
        return doctorId;
    }

    public void setDoctorId(Long doctorId) {
        this.doctorId = doctorId;
    }

    public String getDoctorname() {
        return doctorname;
    }

    public void setDoctorname(String doctorname) {
        this.doctorname = doctorname;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getZipcode() {
        return zipcode;
    }

    public void setZipcode(String zipcode) {
        this.zipcode = zipcode;
    }

}




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.