Hi, can anybody give me idea how to change the foreign key into something like bigint() type or just save the id of parentId instead of object itself. I just started using Hibernate 3 and annotation. And it's giving me a default type of tinyblob and saving the object literally which is pain in file size.
Here is what im doing:
Code:
@Entity @Table(name="table_parent")
public class ParentTable extends BaseObject {
private Long id;
private String name;
private String description;
public ParentTable () {}
@Id @GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Column(name="name", length=50)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name="description", length=50)
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@OneToMany (cascade = {CascadeType.ALL})
@JoinColumn (name="parentTable_id")
private Set<ChildTable> child_tables = new HashSet();
Code:
@Entity @Table(name="child_table")
public class ChildTable extends BaseObject {
private Long id;
private String gsID;
private String description;
public ChildTable () {}
@Column(name="gsID", length=50)
public String getGsID() {
return gsID;
}
public void setGsID(String gsID) {
this.gsID = gsID;
}
@Column(name="description", length=50)
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Id @GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@ManyToOne
@JoinColumn (name="parentTable_id")
private Replica parentTable;
Any comments, suggestion is greatly appreciated.