-->
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.  [ 4 posts ] 
Author Message
 Post subject: Insert problem
PostPosted: Wed Sep 16, 2009 4:30 pm 
Newbie

Joined: Wed Sep 16, 2009 4:21 pm
Posts: 2
I have a mapping class

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.Type;

@Entity
@Table(name = "tags_temp")
public class TagsTemp {
@Id
@Column(name = "sno")
private int sno;
@Id
@Column(name = "tag_name")
private String tagName;
@Column(name = "tag_imp")
private int tagImp;

public TagsTemp() {}

public int getSno() {return sno;}

public void setSno(int sno) {this.sno = sno;}

public String getTagName() {return tagName;}

public void setTagName(String tagName) {this.tagName = tagName;}

public int getTagImp() {return tagImp;}

public void setTagImp(int tagImp) { this.tagImp = tagImp;}

}


primary key is (sno,tagname)


when i try to insert using :

TagsTemp crtt = new TagsTemp();
tt.setSno(sno);
tt.setTagImp(4);
tt.setTagName("hi");
session.save(tt);

it gives me error : field tagName doesn't have a default value
if i remove @Id from tagname..it works fine

Please tell me how to go about it ?


Top
 Profile  
 
 Post subject: Re: Insert problem
PostPosted: Thu Sep 17, 2009 5:46 am 
Beginner
Beginner

Joined: Sat Aug 01, 2009 5:28 am
Posts: 42
hi captain
it may help you

i think you are using composite primary key
for that u must use
Mapped Composite Primary Key Class or Embedded Composite Primary Key Class
i found something on following link
http://download.oracle.com/docs/cd/B321 ... cfg001.htm

_________________
Warm Regards,
Tarun Walia


Top
 Profile  
 
 Post subject: Re: Insert problem
PostPosted: Thu Sep 17, 2009 4:01 pm 
Newbie

Joined: Wed Sep 16, 2009 4:21 pm
Posts: 2
I have now primary key class containing (sno,tagname)

and mapping class containing (primarykeyclass and tagimp)


how can i delete all rows with sno = 1 ?


Top
 Profile  
 
 Post subject: Re: Insert problem
PostPosted: Fri Sep 18, 2009 4:07 am 
Beginner
Beginner

Joined: Sat Aug 01, 2009 5:28 am
Posts: 42
it may be like that

..delete.. where TagsTemp.containing.sno=1

_________________
Warm Regards,
Tarun Walia


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

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.