-->
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: How to change reference type of foreign key.
PostPosted: Thu Aug 27, 2009 8:41 am 
Newbie

Joined: Wed Aug 26, 2009 3:29 am
Posts: 5
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.


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.