मेरे पास एक फॉर्म है और इस फ़ॉर्म को मेरे रिकॉर्ड को अपडेट करने की आवश्यकता है लेकिन स्पष्ट रूप से अपडेट नहीं हो रहा है और मुझे त्रुटि संदेश नीचे आ गया है। इस अपवाद को 4 दिनों में निपटाना और मैं एक प्रश्न पूछने का फैसला करता हूं। अगर आपको अतिरिक्त जानकारी चाहिए तो मैं कुछ जोड़ सकता हूं।विभिन्न इकाइयों के साथ जेपीए प्रबंधित मैपिंग त्रुटि
जेएसपी अपवाद;
MergeContext#attempt to create managed -> managed mapping with different entities: [main.model.Users#1]; [main.model.Users#1]; nested exception is java.lang.IllegalStateException: MergeContext#attempt to create managed -> managed mapping with different entities: [main.model.Users#1]; [main.model.Users#1]
जावा अपवाद;
java.lang.IllegalStateException: MergeContext#attempt to create managed -> managed mapping with different entities: [main.model.Users#1]; [main.model.Users#1]
नियंत्रक; इसकी स्थिति उपयोगकर्ता और डोमेन जानकारी फॉर्म से प्राप्त होती है और इसे डीबी में सहेजती है;
@PostMapping("/save-personel-info")
public String savePersonelInfo(@RequestParam int id, HttpServletRequest request, @ModelAttribute("Users") Users users, @ModelAttribute("Positions") Positions positions, @ModelAttribute("Domains") Domains domains, ModelMap model){
usersService.save(users);
request.setAttribute("mode", "MODE_USERS");
return "redirect:/index";
}
सेवा;
@Service
@Transactional
public class UsersService {
public void save(Users users){
usersRepository.save(users);
}
}
फॉर्म;
<form:form method="POST" action="/save-personel-info" modelAttribute="Users">
<tr>
<form:input id="1-1-0" type="hidden" class="form-control" path="id"/>
<td><form:input id="1-1-0" type="text" class="form-control" path="username" /></td>
<td><form:input id="1-1-0" type="text" class="form-control" path="mail" /></td>
<td>
<form:select path="Positions" class="form-control">
<form:options items="${Pst}" itemValue="id" itemLabel="position_name" />
</form:select>
</td>
<td>
<form:select path="Domains" class="form-control">
<form:options items="${Domains}" itemValue="id" itemLabel="domain_name" />
</form:select>
</td>
</tr>
<input type="submit" value="Submit" />
</form:form>
उपयोगकर्ता कक्षा;
@Component
@Entity
public class Users {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public long id;
public String username;
public String mail;
@Temporal(TemporalType.DATE)
public Date enrolment_date;
@ManyToOne(cascade = CascadeType.ALL)
public Domains domains;
@ManyToOne(cascade = CascadeType.ALL)
public Positions positions;
@OneToMany(targetEntity = UserLanguages.class, mappedBy = "users", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
public Set<UserLanguages> userlanguages = new HashSet<UserLanguages>();
@OneToMany(targetEntity = UserCertificates.class, mappedBy = "users", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
public Set<UserCertificates> usercertificates = new HashSet<UserCertificates>();
@OneToMany(targetEntity = UserKnowledge.class, mappedBy = "users", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
public Set<UserKnowledge> userknowledge = new HashSet<UserKnowledge>();
"विभिन्न संस्थाओं के साथ प्रबंधित मैपिंग" का अर्थ क्या है, मैं इस त्रुटि संदेश का शोध करता हूं लेकिन मुझे लगता है कि कोई भी यह त्रुटि नहीं प्राप्त करता है। Hibernate-orm
वही समस्या। अगर आप इस मुद्दे को पहले ही हल कर चुके हैं, तो कृपया मुझे बताएं। – semenchikus
@semenchikus मेरे उत्तर पर एक नज़र डालें – naXa