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;
}
}