mappedBy
मानचित्र से क्या है? या, बल्कि, यह क्या नक्शा करना चाहिए?@OneToMany मैप किए गए मानचित्र _____
headers
प्रति @OneToMany
docs रूप @Entity
Foo
को नक्शे नीचे दिए गए क्षेत्र? और फिर Foo
javax.mail.Header
के लिए एक रैपर होगा?
package net.bounceme.dur.usenet.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.mail.Header;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.persistence.*;
@Entity
public class Articles implements Serializable {
private static final long serialVersionUID = 1L;
private static final Logger LOG = Logger.getLogger(Articles.class.getName());
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column
private String subject;
@OneToMany(mappedBy="foo") //a wrapper for Header is needed?
private List<Header> headers = new ArrayList<>();
public Articles() {
}
public Articles(Message message) {
try {
subject = message.getSubject();
} catch (MessagingException ex) {
Logger.getLogger(Articles.class.getName()).log(Level.SEVERE, null, ex);
}
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Articles)) {
return false;
}
Articles other = (Articles) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return subject;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
}
समझने की चमक, lemme इसे आजमाएं :) – Thufir
ठीक है, लेकिन मुझे 'अपवाद विवरण मिलता है: [class net.bounceme.dur.usenet.model.Articles] एक गैर-इकाई [वर्ग javax.mail.Header] का उपयोग करता है संबंध विशेषता [फ़ील्ड हेडर] में लक्षित इकाई। इसलिए मुझे उस पर पुनर्विचार करना होगा। इसके अलावा, यह बहुत से लोगों के बारे में सोचने के लिए आएगा, लेकिन मैं डेटाबेस में हर संभव शीर्षलेख नहीं चाहता - लेकिन यह सड़क से नीचे है। मुझे लगता है कि इस सवाल का जवाब है। धन्यवाद :) – Thufir