facebook

@GeneratedValue not getting applied

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #352313 Reply

    dknutson
    Member

    Going 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?

    #352314 Reply

    dknutson
    Member

    This 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)

    #352327 Reply

    dknutson,

    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.

    #352335 Reply

    dknutson
    Member

    Gave that a try – no change. I’ll repost this as suggested

    #352346 Reply

    dknutson,

    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.

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: @GeneratedValue not getting applied

You must be logged in to post in the forum log in