में @EmbeddedId से बैकरेफर सेट करने के लिए कैसे करें किसी को पता है कि जेपीए @EmbeddedId
के भीतर से बैकरेफर स्थापित करना संभव है या नहीं।जेपीए
इसलिए उदाहरण के लिए वहाँ
@Entity
public class Entity1 {
@Id
@GeneratedValue
private String identifier;
private Entity1 relationToEntity1;
//Left out the getters and setters for simplicity
}
और एक जटिल एम्बेडेड आईडी के साथ एक दूसरे इकाई फॉर्म की एक इकाई है। इस दूसरी इकाई का एक हिस्सा इसकी मूल इकाई का संदर्भ है। इसलिए जैसा:
Exception [EclipseLink-93] (Eclipse Persistence Services - 1.1.0.r3639-SNAPSHOT):
org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The table [ENTITY1] is not present in this descriptor.
Descriptor: RelationalDescriptor(test.Entity2 --> [DatabaseTable(ENTITY2)])
@Entity
public class Entity2 {
@EmbeddedId private Entity2Identifier id;
//Left out the getters and setters for simplicity.
}
@Embedabble
public class Entity2Identifier {
private String firstPartOfIdentifier;
private Entity1 parent;
//Left out the getters and setters for simplicity.
}
जब मैं जेपीए के माध्यम से इस तरह के एक निर्माण को बचाने की कोशिश एक डेटाबेस के लिए (कार्यान्वयन EclipseLink है) मैं प्रपत्र के कई अपवाद मिल
क्या किसी को ऐसी समस्या का सामना करना पड़ा है और इसका कोई समाधान है?
ठीक है। मुझे लगता है कि मेरा उदाहरण सरल था। माता-पिता में वास्तव में एक जटिल एम्बेडेड आईडी होती है, जिसमें दो तार होते हैं। यही कारण है कि मैं बस इसकी आईडी का संदर्भ नहीं दे सकता। – ali
कि रूप में अच्छी तरह सरल है। मैं इकाई पर एक EmbeddedId उपयोग करने के लिए 1. –
@MapsId विजेता है मेरी उदाहरण अद्यतन किया है ऊपर! बहुत उपयोगी –