- This topic has 1 reply, 2 voices, and was last updated 13 years, 6 months ago by
jkennedy.
-
AuthorPosts
-
tilo2k2MemberHello,
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.
jkennedyMemberIf you would like to post your generated DAO and Entity for this class I will take a look.
Thanks,
Jack -
AuthorPosts