Hibernate Db2 Sql Error Sqlcode=-407 Sqlstate=23502
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site
Db2 Colno
About Us Learn more about Stack Overflow the company Business Learn more about db2 sql error: sqlcode=-407, sqlstate=23502, sqlerrmc=*n hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss how to find table name using table id in db2 Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Inserting a row into
Sqlstate 23502 Postgresql
DB2 from a sub-select - NULL error up vote 4 down vote favorite I am trying to insert a row into a table, using a value that is derived from another table. Here is the SQL statement that I am trying to use: INSERT INTO NextKeyValue(KeyName, KeyValue) SELECT 'DisplayWorkItemId' AS KeyName, (MAX(work_item_display_id) + 1) AS KeyValue FROM work_item; So, I am trying to create a
Sqlcode: -407, Sqlstate: 23502
row in NextKeyValue that has 'KeyName' of 'DisplayWorkItemId' and 'KeyValue' of one more than the maximum value in work_item.work_item_display_id. The SELECT statement in the above query returns the expected result, when I run it on its own. The whole SQL query is giving me the following error, though: Error: DB2 SQL Error: SQLCODE=-407, SQLSTATE=23502, SQLERRMC=TBSPACEID=2, TABLEID=75, COLNO=2, DRIVER=3.50.152 SQLState: 23502 ErrorCode: -407 What does this mean, and what is wrong with my query? sql db2 share|improve this question edited May 17 '09 at 17:29 asked May 17 '09 at 3:13 pkaeding 18.6k2173120 +1 I suggest you change the title of the question to something like "Inserting a row from sub-select - NULL error", and add "SQL" tag, since this problem is generic and not DB2-specific. –Roee Adler May 17 '09 at 5:59 good idea. I just did it. –pkaeding May 17 '09 at 17:29 add a comment| 1 Answer 1 active oldest votes up vote 10 down vote accepted The most probable explanation is that you have additional columns in NextKeyValue table that can't accept NULL values, and this INSERT statement is "trying" to put NULL in them.
here for tbspaceid a quick overview of the site Help
Db2 Sql Error: Sqlcode=-117, Sqlstate=42802
Center Detailed answers to any questions you might have Meta Discuss the sql0407n workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring http://stackoverflow.com/questions/873828/inserting-a-row-into-db2-from-a-sub-select-null-error developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; http://stackoverflow.com/questions/4555732/problem-in-persisting-object-using-jpa it only takes a minute: Sign up problem in persisting object using jpa up vote 1 down vote favorite I am using jpa to persist a object. When i try to persist it i get following exception: Create failure,Error occurred while create Chargebasis
and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor. Announcement http://forum.spring.io/forum/spring-projects/data/100130-not-able-to-understand-hibernate-exception-reason Announcement Module Collapse No announcement yet. Not able to understand hibernate exception reason Page Title Module Move Remove Collapse X Conversation Detail Module Collapse Posts Latest Activity https://gist.github.com/901475 Search Forums Page of 1 Filter Time All Time Today Last Week Last Month Show All Discussions only Photos only Videos only Links only Polls only db2 sql Filtered by: Clear All new posts vishal1398 Junior Member Join Date: Apr 2011 Posts: 9 #1 Not able to understand hibernate exception reason Apr 13th, 2011, 01:30 AM i am using hibernate template to save date.after data is saved,while leaving the hibernate .i am getting this exception.i am using cglib proxy for Spring db2 sql error Aop Proxy object..if i dont instantiate this persistent bean in the spring context file than this is working fine.so problem look somewhere with persistence of the proxy object in the database...can anyone provide solution to this i have tried to google this ,but cudnt find correct solution for this problem problem look similar to this. we are invoking transaction in the service layer and all the methods are declared in the dao layer.one more problem is that i am not able to catch this exception.because this hibernate transaction manager commit is going out of scope. service layer Code: Transactional(propagation = Propagation.REQUIRES_NEW) public void invokeService() { try { //var 1 and var 2 are spring bean dao.addex1(var1, var2); dao.addex2(var1, var2,); dao.addEx3(var1, var2); } catch (CustomException e) { System.out.println("i m here"); e.printStackTrace(); } spring config file Code: a GitHub account Sign in Create a gist now Instantly share code, notes, and snippets. Star 0 Fork 0 Eugeny/gist:901475 Created Apr 4, 2011 Embed What would you like to do? Embed Embed this gist in your website. Embed Share Copy sharable URL for this gist. Share Clone via HTTPS Clone with Git or checkout with SVN using the repository's web address. HTTPS Learn more about clone URLs Download ZIP Code Revisions 1 Raw gistfile1.txt 14:01:25,028 WARN JDBCExceptionReporter:100 - SQL Error: -407, SQLState: 23502 14:01:25,028 ERROR JDBCExceptionReporter:101 - DB2 SQL Error: SQLCODE=-407, SQLSTATE=23502, SQLERRMC=TBSPACEID=2, TABLEID=17, COLNO=3, DRIVER=3.53.95 Exception in thread "main" org.springframework.orm.jpa.JpaSystemException: org.hibernate.exception.ConstraintViolationException: could not insert: [fksis.domain.entities.Message]; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not insert: [fksis.domain.entities.Message] at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:311) at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:369) at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:58) at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:163) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopPro