- This topic has 4 replies, 2 voices, and was last updated 10 years, 1 month ago by support-pradeep.
-
AuthorPosts
-
dknutsonMemberGoing thru the Spring CRUD tutorial and I’m sooo close to having it worked out. One problem remains.
I’m doing the tutorial with two Sql2005 tables. PartTickets (PT) and TicketNotes (TN). They have the relationship one PT and have many TN’s
Table PartTickets has a primary key TID which is set to auto increment.
Table TicketNotes has a primary key EntryID which is set to auto-increment
Table TicketNotes also has a foreign key to PartTickets.In the domain file for PartTickets, I’ve encoded TID as follows
@Column(name = “TID”, nullable = false)
@Basic(fetch = FetchType.EAGER)
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@XmlElement
Integer tid;In the domain file for TicketNotes I’ve encoded EntryID as follows
@Column(name = “EntryID”, nullable = false)
@Basic(fetch = FetchType.EAGER)
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@XmlElement
Integer entryId;Everything is fine until I try to add a new TicketNote then the form includes a blank entry spot for EntryID and of course that won’t work.
So, what did I do wrong to stop it from picking up the A@GeneratedValue?
dknutsonMemberThis is the error it throws –
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.DataException: could not insert: [org.srac.testfk2.domain.Ticketnotes]
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:147)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
support-pradeepMemberdknutson,
Can you try replacing the auto increment @GeneratedValue with the following and see if it works.
@GeneratedValue(strategy = javax.persistence.GenerationType.IDENTITY)
This is a development related query and I suggest you to cross post on development forums (such as http://www.stackoverflow.com ) for better support on this query.
Let us know if you face any issues with MyEclipse.
dknutsonMemberGave that a try – no change. I’ll repost this as suggested
support-pradeepMemberdknutson,
Sorry that the suggestion didn’t work. Hope you will get a resolution to the problem in the development forums.
Let us know if you see any issues with MyEclipse.
-
AuthorPosts