-->
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.  [ 7 posts ] 
Author Message
 Post subject: update on Select
PostPosted: Tue May 18, 2010 3:38 pm 
Newbie

Joined: Wed May 12, 2010 8:29 pm
Posts: 4
I have an object mapped to to tables. I have a DAO for my object, and when I do a findall() with my DAO, and commit the transacation I get 2 update queries 1 for each table. My Findall() looks like this:

Code:
/** @return List of ALL Employee instances */
  public List findAll()
  {      
    log.error("finding All Employees");
    String q = "";
    String fmode = "";
    try
    {
      Session sess = getSession();
      sess.beginTransaction();
      sess.flush();
      sess.getTransaction().commit();
      log.error("Really finding all Employees now");
      sess = getSession();
      sess.beginTransaction();
      String queryString = "SELECT * FROM Employee ORDER BY pcn ASC";
      Query queryObject = sess.createQuery(queryString);
      List li = sess.createQuery(queryString).list();
                    //.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();
      q = queryObject.getQueryString();     
     
      fmode = sess.getFlushMode().toString();
      sess.getTransaction().commit();
      return li;
    }
    catch (RuntimeException re)
    {
       log.error("find all failed. hql: " + q + " flush mode: " + fmode, re);
       throw re;
    }
  }


As you can see I even tried explicitely open, flush, commit, and close to make sure something else wasn't getting added to my select.

My Mapping file looks like this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
          "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<!-- Generated Mar 9, 2010 11:59:10 AM by Hibernate Tools 3.2.4.GA -->
<!-- TODO: fix this file to properly map NameTable/PcnTAble for employee -->
<hibernate-mapping>
  <class catalog="Personnel" schema="dbo" table="`Name Table`"
         name="us.ak.state.revenue.cssd.Personnel.Employee.Employee" >
    <id name="nameIrc" type="int">
      <column name="`Name IRC`"/>
      <generator class="identity"/>
    </id>
    <property name="lastName" type="string">
      <column name="`Last Name`" not-null="true"/>
    </property>
    <property name="firstName" type="string">
      <column name="`First Name`" not-null="true"/>
    </property>
    <property name="ini" type="string">
      <column name="Ini"/>
    </property>
    <property name="nickname" type="string">
      <column name="Nickname" not-null="true"/>
    </property>
    <property name="ssn" type="string">
      <column name="SSN"/>
    </property>
    <property name="Emp_num" type="java.lang.Integer">
      <column name="`Emp#`"/>
    </property>
    <!-- to save space many other properties in this file have been removed  -->
    <property name="processSrvLic" type="boolean">
      <column name="ProcessSrvLic" not-null="true"/>
    </property>
    <set fetch="select" inverse="true" lazy="true" name="systemTables" table="SystemTable">
      <key>
        <column name="Name IRC"/>
      </key>
      <one-to-many class="us.ak.state.revenue.cssd.Personnel.dao.SystemTable"/>
    </set>
    <!-- I think the join element goes here -->
    <join catalog="Personnel" schema="dbo" table="`PCN-Table`" >
      <!--<key column="PCN"  on-delete="noaction" unique="true" /> -->
      <key column="`Name IRC`" on-delete="noaction" unique="true"
           property-ref="nameIrc" />
     
      <property name="pcn" type="string" unique="true" not-null="true">
        <column name="PCN"/>
      </property>
      <!--
      <id name="pcn" type="string">
        <column name="PCN"/>
        <generator class="assigned"/>
      </id>
      -->
      <!-- -->
      <property name="typeOfPcn" type="string">
        <column name="`Type of PCN`"/>
      </property>
      <property name="systPcn" type="string">
        <column name="`SYST PCN`"/>
      </property>
      <property name="mailstop" type="string">
        <column name="Mailstop"/>
      </property>
      <!-- to save space many other properties in this file have been removed -->
      <property name="comments" type="string">
        <column name="Comments"/>
      </property>
      <!-- TODO: fix this line - property-ref is throwing a nullreference exception
      <many-to-one name="nameIrc" column="`Name IRC`"
                   class="us.ak.state.revenue.cssd.Personnel.Employee.Employee"
                   property-ref="nameIrc" >
      </many-to-one>
      -->
    </join>
  </class>
</hibernate-mapping>


Thanks in advance for any help.


Top
 Profile  
 
 Post subject: Re: update on Select
PostPosted: Tue May 18, 2010 6:19 pm 
Regular
Regular

Joined: Tue May 11, 2010 5:50 pm
Posts: 54
Location: Norman, Ok, U.S.A
First, you do not need to flush and commit before doing anything, instead try calling session.clear(). Also you don't need to commit after you have run a find.
Leave commit for save/update/delete.

Just create the session and run the query in a single transaction, so try taking the first block out where you are creating the session and a transaction and calling an empty commit.


Top
 Profile  
 
 Post subject: Re: update on Select
PostPosted: Tue May 18, 2010 6:47 pm 
Newbie

Joined: Wed May 12, 2010 8:29 pm
Posts: 4
I originally added the empty transaction because I wanted to make absolutely sure that when I committed my Select that no other queries where getting added to the work being done.

When I look at the logging output it all looks fine up until "Really finding all Employees now" It's after Error log statement that bad things happen. The select looks about like what I think it should, but then it's immediately followed by two update queries. One for each table. I tried using a rollback instead of a commit at the end of my select transaction before and I still ended up with other wierd issues once the page loaded.

I really think the problem is probably something to do with my mapping file. My table mapping is "non-standard" from what I can tell about hibernate standards.

the Name table has a primary Key NameIRC and the PCN-Table has a primary Key PCN, but it links to the Name Table on the NameIRC field of itself.

Here is the log file output:
Code:
ERROR - EmployeeDAO                - Really finding all Employees now
Hibernate: select employee0_.[Name IRC] as Name1_9_, employee0_.[Last Name] as Last2_9_, employee0_.[First Name] as First3_9_, employee0_.Ini as Ini9_, employee0_.Nickname as Nickname9_, employee0_.SSN as SSN9_, employee0_.[Emp#] as Emp7_9_, employee0_.Probation as Probation9_, employee0_.[Hire Date] as Hire9_9_, employee0_.[Term Date] as Term10_9_, employee0_.[Merit Anniversary] as Merit11_9_, employee0_.[Pay Step] as Pay12_9_, employee0_.[Next Eval] as Next13_9_, employee0_.[Arrive Work] as Arrive14_9_, employee0_.[Depart Work] as Depart15_9_, employee0_.[Lunch Start] as Lunch16_9_, employee0_.[Lunch End] as Lunch17_9_, employee0_.[Notary Expiration] as Notary18_9_, employee0_.[Parking Tag #] as Parking19_9_, employee0_.[Acting PCN] as Acting20_9_, employee0_.[CardGroup#] as CardGroup23_9_, employee0_.ProcessSrvLic as Process22_9_, employee0_1_.PCN as PCN1_, employee0_1_.[Type of PCN] as Type3_1_, employee0_1_.[SYST PCN] as SYST4_1_, employee0_1_.Mailstop as Mailstop1_, employee0_1_.SubTeam as SubTeam1_, employee0_1_.[Phone Prefix] as Phone7_1_, employee0_1_.[Phone Ext] as Phone8_1_, employee0_1_.[Fax Prefix] as Fax9_1_, employee0_1_.[Fax Ext] as Fax10_1_, employee0_1_.Pager as Pager1_, employee0_1_.[Position Title] as Position12_1_, employee0_1_.[Supervisor PCN] as Supervisor13_1_, employee0_1_.[Phone List?] as Phone14_1_, employee0_1_.[Phone List Description] as Phone15_1_, employee0_1_.[Supervisory?] as Supervi16_1_, employee0_1_.[PCN List?] as PCN17_1_, employee0_1_.[Pay Range] as Pay18_1_, employee0_1_.[Acting IRC] as Acting19_1_, employee0_1_.[Acting End Date] as Acting20_1_, employee0_1_.Comments as Comments1_ from Personnel.dbo.[Name Table] employee0_ inner join Personnel.dbo.[PCN-Table] employee0_1_ on employee0_.[Name IRC]=employee0_1_.[Name IRC] order by employee0_1_.PCN ASC
Hibernate: update Personnel.dbo.[Name Table] set [Last Name]=?, [First Name]=?, Ini=?, Nickname=?, SSN=?, [Emp#]=?, Probation=?, [Hire Date]=?, [Term Date]=?, [Merit Anniversary]=?, [Pay Step]=?, [Next Eval]=?, [Arrive Work]=?, [Depart Work]=?, [Lunch Start]=?, [Lunch End]=?, [Notary Expiration]=?, [Parking Tag #]=?, [Acting PCN]=?, [CardGroup#]=?, ProcessSrvLic=? where [Name IRC]=?
Hibernate: update Personnel.dbo.[PCN-Table] set PCN=?, [Type of PCN]=?, [SYST PCN]=?, Mailstop=?, SubTeam=?, [Phone Prefix]=?, [Phone Ext]=?, [Fax Prefix]=?, [Fax Ext]=?, Pager=?, [Position Title]=?, [Supervisor PCN]=?, [Phone List?]=?, [Phone List Description]=?, [Supervisory?]=?, [PCN List?]=?, [Pay Range]=?, [Acting IRC]=?, [Acting End Date]=?, Comments=? where [Name IRC]=?
WARN  - JDBCExceptionReporter      - SQL Error: 2601, SQLState: S0003
ERROR - JDBCExceptionReporter      - Cannot insert duplicate key row in object 'PCN-Table' with unique index 'PCN'.
ERROR - tractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: could not update: [us.ak.state.revenue.cssd.Personnel.Employee.Employee#1]
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2421)
        at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2303)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2603)
        at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
        at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
        at us.ak.state.revenue.cssd.Personnel.Employee.EmployeeDAO.findAll(EmployeeDAO.java:361)
        at us.ak.state.revenue.cssd.Personnel.emp_int_maint.<init>(emp_int_maint.java:120)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at java.lang.Class.newInstance0(Class.java:355)
        at java.lang.Class.newInstance(Class.java:308)
        at wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:58)
        at wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:267)
        at wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:286)
        at wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:205)
        at wicket.request.compound.DefaultEventProcessorStrategy.processEvents(DefaultEventProcessorStrategy.java:65)
        at wicket.request.compound.AbstractCompoundRequestCycleProcessor.processEvents(AbstractCompoundRequestCycleProcessor.java:57)
        at wicket.RequestCycle.doProcessEventsAndRespond(RequestCycle.java:896)
        at wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:929)
        at wicket.RequestCycle.step(RequestCycle.java:1010)
        at wicket.RequestCycle.steps(RequestCycle.java:1084)
        at wicket.RequestCycle.request(RequestCycle.java:454)
        at wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:219)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert duplicate key row in object 'PCN-Table' with unique index 'PCN'.
        at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:196)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1454)
        at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:388)
        at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:338)
        at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4026)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1416)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:185)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:160)
        at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:306)
        at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2403)
        ... 49 more
ERROR - EmployeeDAO                - find all failed. hql: FROM Employee ORDER BY pcn ASC flush mode: AUTO
org.hibernate.exception.SQLGrammarException: could not update: [us.ak.state.revenue.cssd.Personnel.Employee.Employee#1]
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2421)
        at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2303)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2603)
        at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
        at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
        at us.ak.state.revenue.cssd.Personnel.Employee.EmployeeDAO.findAll(EmployeeDAO.java:361)
        at us.ak.state.revenue.cssd.Personnel.emp_int_maint.<init>(emp_int_maint.java:120)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at java.lang.Class.newInstance0(Class.java:355)
        at java.lang.Class.newInstance(Class.java:308)
        at wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:58)
        at wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:267)
        at wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:286)
        at wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:205)
        at wicket.request.compound.DefaultEventProcessorStrategy.processEvents(DefaultEventProcessorStrategy.java:65)
        at wicket.request.compound.AbstractCompoundRequestCycleProcessor.processEvents(AbstractCompoundRequestCycleProcessor.java:57)
        at wicket.RequestCycle.doProcessEventsAndRespond(RequestCycle.java:896)
        at wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:929)
        at wicket.RequestCycle.step(RequestCycle.java:1010)
        at wicket.RequestCycle.steps(RequestCycle.java:1084)
        at wicket.RequestCycle.request(RequestCycle.java:454)
        at wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:219)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert duplicate key row in object 'PCN-Table' with unique index 'PCN'.
        at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:196)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1454)
        at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:388)
        at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:338)
        at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4026)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1416)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:185)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:160)
        at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:306)
        at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2403)
        ... 49 more
ERROR - RequestCycle               - could not update: [us.ak.state.revenue.cssd.Personnel.Employee.Employee#1]
org.hibernate.exception.SQLGrammarException: could not update: [us.ak.state.revenue.cssd.Personnel.Employee.Employee#1]
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2421)
        at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2303)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2603)
        at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
        at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
        at us.ak.state.revenue.cssd.Personnel.Employee.EmployeeDAO.findAll(EmployeeDAO.java:361)
        at us.ak.state.revenue.cssd.Personnel.emp_int_maint.<init>(emp_int_maint.java:120)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at java.lang.Class.newInstance0(Class.java:355)
        at java.lang.Class.newInstance(Class.java:308)
        at wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:58)
        at wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:267)
        at wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:286)
        at wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:205)
        at wicket.request.compound.DefaultEventProcessorStrategy.processEvents(DefaultEventProcessorStrategy.java:65)
        at wicket.request.compound.AbstractCompoundRequestCycleProcessor.processEvents(AbstractCompoundRequestCycleProcessor.java:57)
        at wicket.RequestCycle.doProcessEventsAndRespond(RequestCycle.java:896)
        at wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:929)
        at wicket.RequestCycle.step(RequestCycle.java:1010)
        at wicket.RequestCycle.steps(RequestCycle.java:1084)
        at wicket.RequestCycle.request(RequestCycle.java:454)
        at wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:219)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:619)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert duplicate key row in object 'PCN-Table' with unique index 'PCN'.
        at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:196)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1454)
        at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:388)
        at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:338)
        at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4026)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1416)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:185)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:160)
        at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:306)
        at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
        at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2403)
        ... 49 more



Hope that helps you understand my problem.


Top
 Profile  
 
 Post subject: Re: update on Select
PostPosted: Wed May 19, 2010 11:52 am 
Regular
Regular

Joined: Tue May 11, 2010 5:50 pm
Posts: 54
Location: Norman, Ok, U.S.A
It may be because you have unique as true somewhere it should not be it seem like...


Top
 Profile  
 
 Post subject: Re: update on Select
PostPosted: Wed May 19, 2010 12:14 pm 
Regular
Regular

Joined: Tue May 11, 2010 5:50 pm
Posts: 54
Location: Norman, Ok, U.S.A
Another thing that I see is wrong is that you are writing a SQL query and calling the HQL query creater.
Either write the query as

Code:
Query query = session.createQuery("From Employee");
query.orderBy(OrderBy.Asc..);

or call
Code:
session.createSqlQuery(queryString);


Top
 Profile  
 
 Post subject: Re: update on Select
PostPosted: Wed May 19, 2010 6:08 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
I had a similar issue one time (but without errors). It was caused by a simple mistake in the Java class so that Hibernate thought that I had modified it. It could for example happen if the getter for a property returns the incorrect value:

Code:
public String getFoo(){
  return foo;
}
public void setFoo(String foo){
  this.foo = foo;
}
public String getBar(){
  return foo; // <--- Should return 'bar' not 'foo'
}
public void setBar(String bar){
  this.bar = bar;
}


Make sure that your Employee class is correct.


Top
 Profile  
 
 Post subject: Re: update on Select
PostPosted: Thu May 20, 2010 4:13 pm 
Newbie

Joined: Wed May 12, 2010 8:29 pm
Posts: 4
nordborg, thanks for the help. I had been getting issues with null fields, and didn't want to mess with it anymore so I had changed a lot of my getters to following the pattern below
Code:
public String getMyField()
{ return ((null != myfield)? myfield : ""); }

I guess that was triggering the update, weird.

I just hope when I get to the bit where I actually do want to make updates that this issue doesn't show up again.


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

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.