As I mentioned userDTO != userDTO1... And please use code tags...
As I mentioned userDTO != userDTO1... And please use code tags...
Marten Deinum
Java Consultant / Pragmatist / Open Source Enthousiast / Author
Pro Spring MVC: With Web Flow
Conspect
Have you read the reference guide.
Use the [ code ] tags, young padawan
userDTO1 is an object of UserDTO as you can see. and userDTO is also an object of UserDTO too.
here is UserDTO
and userPersonalInfoDTOCode:package com.peanuts.blackboard.database.dto; /** * @version=1.0 * @author vbinda * */ public class UserDTO { private int userId; private String userName; private int userSchoolId; private String userPassword; private String userRole; private String userStatus; private UserPersonalInfoDTO userPersonalInfoDTO; public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public int getUserSchoolId() { return userSchoolId; } public void setUserSchoolId(int userSchoolId) { this.userSchoolId = userSchoolId; } public String getUserPassword() { return userPassword; } public void setUserPassword(String userPassword) { this.userPassword = userPassword; } public String getUserRole() { return userRole; } public void setUserRole(String userRole) { this.userRole = userRole; } public String getUserStatus() { return userStatus; } public void setUserStatus(String userStatus) { this.userStatus = userStatus; } public UserPersonalInfoDTO getUserPersonalInfoDTO() { return userPersonalInfoDTO; } public void setUserPersonalInfoDTO(UserPersonalInfoDTO userPersonalInfoDTO) { this.userPersonalInfoDTO = userPersonalInfoDTO; } }
it does not matter If i name the object usr or usr1 or userDTO1 or usrDTO, If my objects and named correctly in POJO classes. userDTO1 will be set to userDTO in pojo.Code:package com.peanuts.blackboard.database.dto; public class UserPersonalInfoDTO { private int userId; private String userFirstName; private String userLastName; private String userEmail; private String userContactNumber; private String userAddress; private UserDTO userDTO; public int getUserId() { return userId; } public void setUserId(int userId) { this.userId = userId; } public String getUserFirstName() { return userFirstName; } public void setUserFirstName(String userFirstName) { this.userFirstName = userFirstName; } public String getUserLastName() { return userLastName; } public void setUserLastName(String userLastName) { this.userLastName = userLastName; } public String getUserEmail() { return userEmail; } public void setUserEmail(String userEmail) { this.userEmail = userEmail; } public String getUserContactNumber() { return userContactNumber; } public void setUserContactNumber(String userContactNumber) { this.userContactNumber = userContactNumber; } public String getUserAddress() { return userAddress; } public void setUserAddress(String userAddress) { this.userAddress = userAddress; } public UserDTO getUserDTO() { return userDTO; } public void setUserDTO(UserDTO userDTO) { this.userDTO = userDTO; } }
Just to make you happy i changed userDTO1 to userDTO. It still throws the same exception.
Is someone still there to help, the problem is not yet resolved.![]()
Sigh... I give up... You really don't have a clue what I'm saying (or I'm writing some not to understand English) or how hibernate relation mappings work.
It doesn't matter if both are instances of UserDTO they have to be the SAME instance.. That is what I tried to explain each post, but apparently miserable failed.
I suggest a read of this about bidirectional mappings.
Marten Deinum
Java Consultant / Pragmatist / Open Source Enthousiast / Author
Pro Spring MVC: With Web Flow
Conspect
Have you read the reference guide.
Use the [ code ] tags, young padawan
Dear Marten,
I totally understand what you are trying to say.
I am using the same instance of UserDTO. I just had it named that way. I corrected it and It is still throwing up the same error.
this was the mistake which you pointed out
it has been corrected toCode:UserDTO userDTO1 = new UserDTO(); userDTO1.setUserName("test"); userDTO1.setUserPassword("temp"); userDTO1.setUserRole("STUDENT"); userDTO1.setUserSchoolId(3333); userDTO1.setUserStatus("ACTIVE"); UserPersonalInfoDTO userPersonalInfoDTO = new UserPersonalInfoDTO(); userPersonalInfoDTO.setUserAddress("test"); userPersonalInfoDTO.setUserContactNumber("3333333" ); userPersonalInfoDTO.setUserEmail("test"); userPersonalInfoDTO.setUserFirstName("test"); userPersonalInfoDTO.setUserLastName("test"); userDTO.setUserPersonalInfoDTO(userPersonalInfoDTO ); userPersonalInfoDTO.setUserDTO(userDTO1); session.save(userDTO);
it still throws the same error..Code:UserDTO userDTO = new UserDTO(); userDTO.setUserName("test"); userDTO.setUserPassword("temp"); userDTO.setUserRole("STUDENT"); userDTO.setUserSchoolId(3333); userDTO.setUserStatus("ACTIVE"); UserPersonalInfoDTO userPersonalInfoDTO = new UserPersonalInfoDTO(); userPersonalInfoDTO.setUserAddress("test"); userPersonalInfoDTO.setUserContactNumber("3333333" ); userPersonalInfoDTO.setUserEmail("test"); userPersonalInfoDTO.setUserFirstName("test"); userPersonalInfoDTO.setUserLastName("test"); userDTO.setUserPersonalInfoDTO(userPersonalInfoDTO ); userPersonalInfoDTO.setUserDTO(userDTO); session.save(userDTO);
If I have understood correctly from the documentation, below code is enough to manage transactions. untill and unless I want to do something special, I would have to add advice on class level, method level etc.
and this is my transaction managerCode:<annotation-driven /> <beans:bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" /> <tx:annotation-driven proxy-target-class="true" mode="proxy" />
because the name is transactionManager i dont need to specify its name in proxy-target-class bean all i need now id add @Transactional to my class.Code:<beans:bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <beans:property name="sessionFactory" ref="sessionFactory" /> </beans:bean>
Any way, I have tried adding advice to the method also. It is still the same.
![]()