-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: unique constraint
PostPosted: Mon Mar 14, 2005 11:46 am 
Newbie

Joined: Tue Sep 07, 2004 9:53 am
Posts: 3
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2.1

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using: oracle 9

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:



I work with Spring & Hibernate and with oracle db

Assume I have a table called users with a column user_name.
I also have a User object.
I want to make sure the user_name is unique so I added a unique constraint on the column.

Now when I try to save a user with a user_name that is already in the database I get a unique constraint violation. (which is good)

My problem is that I get several errors in log which I don’t want to see (see below)

My questions
1. What is the recommended way to check if a field is unique using hibernate?
2. Is there a way to prevent hibernate from writing to the log in ERROR level?

Thanks



16:52:47,332 [tcpConnection-8080-4] ERROR net.sf.hibernate.impl.SessionImpl - Could not synchronize database state with session
net.sf.hibernate.JDBCException: could not update: [com.actimize.domain.permissions.UserHib#3280225]
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:707)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:642)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:52)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2418)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2372)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
at org.springframework.orm.hibernate.HibernateTemplate$20.doInHibernate(HibernateTemplate.java:392)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:176)
at org.springframework.orm.hibernate.HibernateTemplate.flush(HibernateTemplate.java:390)
at com.actimize.dao.PermissionsDaoImpl.saveOrUpdateUser(PermissionsDaoImpl.java:582)
at com.actimize.services.UsersGUIServiceImpl.updateUser(UsersGUIServiceImpl.java:131)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection(AopProxyUtils.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:149)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:116)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:56)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152)
at $Proxy14.updateUser(Unknown Source)
at com.actimize.beans.settings.UserDetailsDataModel.getTableExtraData(UserDetailsDataModel.java:52)
at com.actimize.web.common.DefaultApplicationModel.getTablePreData(DefaultApplicationModel.java:261)
at com.actimize.web.tags.Table.getTableContent(Table.java:72)
at com.actimize.web.tags.Table.getTableContent(Table.java:408)
at com.actimize.web.tags.Table.doStartTag(Table.java:53)
at _userdetails__jsp._jspService(_userdetails__jsp.java:190)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.subservice(Page.java:485)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
at com.caucho.server.http.Invocation.service(Invocation.java:312)
at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:213)
at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:100)
at com.caucho.server.http.QRequestDispatcher.forward(QRequestDispatcher.java:77)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:88)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:238)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:644)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:535)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:321)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
at net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor.proceedWithObject(FilterSecurityInterceptor.java:87)
at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.interceptor(AbstractSecurityInterceptor.java:318)
at net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:78)
at net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter.doFilter(SecurityEnforcementFilter.java:165)
at com.actimize.infrastructure.authentication.ACMSecurityEnforcementFilter.doFilter(ACMSecurityEnforcementFilter.java:69)
at net.sf.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:105)
at com.caucho.server.http.FilterChainFilter.doFilter(FilterChainFilter.java:88)
at net.sf.acegisecurity.ui.AbstractIntegrationFilter.doFilter(AbstractIntegrationFilter.java:170)
at com.caucho.server.http.FilterChainFilter.doFilter(FilterChainFilter.java:88)
at net.sf.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:368)
at net.sf.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:105)
at com.caucho.server.http.FilterChainFilter.doFilter(FilterChainFilter.java:88)
at com.caucho.server.http.Invocation.service(Invocation.java:312)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:221)
at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:163)
at com.caucho.server.TcpConnection.run(TcpConnection.java:137)
at java.lang.Thread.run(Thread.java:536)
Caused by: java.sql.SQLException: ORA-00001: unique constraint (CLEANDB3.USER_IDENTIFIER_UNIQUE) violated

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:233)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:684)
... 58 more


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.