Click here to Skip to main content
15,908,445 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi frnds,

I have two columns names as UserId,SenderId among those UserId is primary key.I am trying to assign the multiple or single SenderId's for each user based on the UserId
now my requirement is if i assigned multiple SenderId's for a particular user then it is not going to allow the duplicate SenderId for that particular user and including all the users also.I defined the SenderId as unique.Can any one give me the hibernate query to do this one.

Thank In Advance.
Posted

1 solution

Your problem can be addressed in two parts.

1) Database-Design - You have a table with two columns UserId[PK] and SenderId[Unique]. You are trying to insert records with same SenderId for multiple users and its not allowing you to do it. Isn't it obvious?

Why you have declared SenderId as Unique when you want to assign a perticular SenderId to multiple users. Remove the Unique constraint and then try again.

2) Hibernate - For Hibenate you may have a look at below link.

Hibernate Getting Started Guide
 
Share this answer
 
Comments
komali Guntur 28-Jul-11 2:11am    
No sir senderid must be unique in the entire table thats why i kept unique constraint for the senderid.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900