facebook

MyEclipse for Spring CRUD – IDENTITY column issue

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

    tilo2k2
    Member

    Hello,

    I am using MyEclipse for Spring v9.1.0 and using Scraffold Spring CRUD application…. for a single table on sql server 2008 db as below

    CREATE TABLE [dbo].[CONFIGURATOR](
    [CONFIGURATOR_ID] [bigint] IDENTITY(1000000,1) NOT NULL,
    [NAME] [varchar](30) NULL,
    [DESCRIPTION] [varchar](300) NULL
    CONSTRAINT [XPKCONFIGURATOR] PRIMARY KEY CLUSTERED
    (
    [CONFIGURATOR_ID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]

    After the code generation is done, I try to add a record without entering the value for [ConfiguratorId] and I get the error about

    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is javax.persistence.PersistenceException: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.testidentity.domain.Configurator
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:656)
    ………………….

    If I enter a value like ‘1000001’ into [ConfiguratorId], I got this error below
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not insert: [com.testidentity.domain.Configurator]
    ….

    java.sql.SQLException: Cannot insert explicit value for identity column in table ‘CONFIGURATOR’ when IDENTITY_INSERT is set to OFF.
    ….

    It seems the generation code does not take care of inserting value for IDENTITY column.

    Please advice and provide directions of how to fix this.

    Many thanks in advance.

    #319272 Reply

    jkennedy
    Member

    If you would like to post your generated DAO and Entity for this class I will take a look.

    Thanks,
    Jack

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: MyEclipse for Spring CRUD – IDENTITY column issue

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