Announcement Announcement Module
Collapse
No announcement yet.
insert problem - id used Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • insert problem - id used

    Hello,

    I work on a project with an existing database, I created a class according to my database :
    Code:
    @RooJavaBean
    @RooToString
    @RooEntity(identifierField = "PUBLISHER_ID", identifierColumn = "PUBLISHER_ID", table = "PUBLISHER", schema = "OKARMA", versionField = "")
    public class Publisher {
    
        @NotNull
        @Column(name = "LABEL")
        @Size(max = 64)
        private String label;
    }
    But there are some data in my DB, when I try to insert a new item, sometimes it failed because the "ID" is already used in the current DB. I think when inserting it use an incremental session id, so how can I do to get an unused ID to insert data ?

    Here are errors message, exception messages :
    Code:
    org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.francetelecom.roo.karmaihm.domain.okarma.Publisher#12]; nested exception is javax.persistence.PersistenceException: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.francetelecom.roo.karmaihm.domain.okarma.Publisher#12]
    And stack trace :
    Code:
    org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:311)
    org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect.ajc$afterThrowing$org_springframework_orm_jpa_aspectj_JpaExceptionTranslatorAspect$1$18a1ac9(JpaExceptionTranslatorAspect.aj:15)
    com.francetelecom.roo.karmaihm.domain.okarma.Publisher_Roo_Entity.ajc$interMethod$com_francetelecom_roo_karmaihm_domain_okarma_Publisher_Roo_Entity$com_francetelecom_roo_karmaihm_domain_okarma_Publisher$persist(Publisher_Roo_Entity.aj:44)
    com.francetelecom.roo.karmaihm.domain.okarma.Publisher.persist(Publisher.java:1)
    com.francetelecom.roo.karmaihm.domain.okarma.Publisher_Roo_Entity.ajc$interMethodDispatch1$com_francetelecom_roo_karmaihm_domain_okarma_Publisher_Roo_Entity$com_francetelecom_roo_karmaihm_domain_okarma_Publisher$persist(Publisher_Roo_Entity.aj)
    com.francetelecom.roo.karmaihm.web.PublisherController_Roo_Controller.ajc$interMethod$com_francetelecom_roo_karmaihm_web_PublisherController_Roo_Controller$com_francetelecom_roo_karmaihm_web_PublisherController$create(PublisherController_Roo_Controller.aj:33)
    com.francetelecom.roo.karmaihm.web.PublisherController.create(PublisherController.java:1)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
    org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    com.springsource.insight.collection.tcserver.request.HttpRequestOperationCollectionValve.invoke(HttpRequestOperationCollectionValve.java:64)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:409)
    java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    java.lang.Thread.run(Thread.java:662)
    I hope you can help me, thank's

  • #2
    Someone know where the insert query is used ?

    Comment


    • #3
      Look at the Publisher_Roo_Entity.aj file, the property annotated with @Id also probably has this annotation @GeneratedValue(strategy = GenerationType.AUTO)

      In this case, I think that hibernate uses a sequence named "HIBERNATE_SEQUENCE" that it created in your DB to generate the ids.

      Comment


      • #4
        thank's a lot, it works!

        Comment

        Working...
        X