निम्न कोड का उपयोग कर:हाइबरनेट: @UniqueConstraint @ManyToOne फ़ील्ड के साथ?
@Entity
@Table(uniqueConstraints=[@UniqueConstraint(columnNames=["account","name"])])
class Friend {
@Id @GeneratedValue(strategy=GenerationType.AUTO)
public Long id
@ManyToOne
public Account account
public String href
public String name
}
मुझे निम्न त्रुटि मिलती है:
org.hibernate.AnnotationException: Unable to create unique key constraint (account, name) on table Friend: account not found
ऐसा लगता है कि इसे @ManyToOne बाधा के साथ करना है, जो मुझे लगता है कि वास्तव में एक अलग UniqueConstraint बनाता है ???
किसी भी मामले में, यदि मैं इसे बाहर लेता हूं, तो UniqueConstraint के बारे में कोई शिकायत नहीं है, लेकिन एक और त्रुटि है जो मुझे विश्वास दिलाती है कि इसे छोड़ दिया जाना चाहिए।
org.hibernate.MappingException: Could not determine type for: com.mksoft.fbautomate.domain.Account, at table: Friend, for columns: [org.hibernate.mapping.Column(account)]
कोई संकेत है कि मैं कैसे बना सकता हूं ऐसी वांछित बाधा (यानी, खाते और नाम का प्रत्येक संयोजन केवल एक बार होता है ???)
धन्यवाद!
मिशा
क्या @ पीटर का समाधान आपके लिए काम करता है? – Reddy