-->
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.  [ 3 posts ] 
Author Message
 Post subject: find method for many-many relationship attempting update
PostPosted: Tue Sep 01, 2009 9:44 pm 
Newbie

Joined: Tue Apr 06, 2004 8:44 am
Posts: 9
My many-to-many mapping is doing a mysterious update. I think that it's getting the data that I need on my query. Why would it try to do an update? I don't call an update here at all...

Code:
"from User as model " +
"where model.userName = '" + user.getUserName() + "' " +
"and model.password = '" + user.getPassword() + "'";


The problem is that it attempts an update when it's done & fails as there is not data in whatever it's trying to store. Below is part of the stack trace & then my mappings...

Code:
20:24:57,030 DEBUG SQL:111 -
    /* update
        com.gtsyn.security.bean.Authorization */ update
            AUTHORIZATION
        set
            AUTH_NAME=?,
            DESCRIPTION=?,
            LAST_UPDATE=?,
            LAST_UPDATE_USER=?,
            APP_ID=?
        where
            AUTH_ID=?
Hibernate:
    /* update
        com.gtsyn.security.bean.Authorization */ update
            AUTHORIZATION
        set
            AUTH_NAME=?,
            DESCRIPTION=?,
            LAST_UPDATE=?,
            LAST_UPDATE_USER=?,
            APP_ID=?
        where
            AUTH_ID=?
20:24:57,030 DEBUG AbstractBatcher:66 - Executing batch size: 1
20:24:57,061 DEBUG AbstractBatcher:418 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
20:24:57,061 DEBUG JDBCExceptionReporter:92 - Could not execute JDBC batch update [/* update com.gtsyn.security.bean.Authorization */ update AUTHORIZATION set AUTH_NAME=?, DESCRIPTION=?, LAST_UPDATE=?, LAST_UPDATE_USER=?, APP_ID=? where AUTH_ID=?]
java.sql.BatchUpdateException: Column 'auth_name' cannot be null


Code:
<class name="User" table="APP_USER">
    <id name="id" type="java.lang.Long">
        <column name="USER_ID" precision="18" scale="0" />
        <generator class="identity" />
    </id>
    <property name="userName" type="string" column="USER_NAME" />
    <property name="password" type="string" column="PASSWORD" />
    <property name="activeDate" type="timestamp" column="ACTIVE_DATE" />
    <property name="inactiveDate" type="timestamp" column="INACTIVE_DATE" />
    <property name="createDate" type="timestamp" column="CREATE_DATE" update="false" />
    <property name="createUser" type="string" column="CREATE_USER" update="false" />
    <property name="lastUpdate" type="timestamp" column="LAST_UPDATE" />
    <property name="lastUpdateUser" type="string" column="LAST_UPDATE_USER" />
    <set name="auths" table="auth_user" lazy="false">
        <key column="USER_ID"/>
        <many-to-many class="com.gtsyn.security.bean.Authorization" column="AUTH_ID" />
    </set>
</class>

<class name="Application" table="APPLICATION">
    <id name="id" type="java.lang.Long">
        <column name="APP_ID" precision="18" scale="0" />
        <generator class="identity" />
    </id>
    <property name="appName" type="string" column="APP_NAME" />
    <property name="description" type="string" column="DESCRIPTION" />
    <property name="activeDate" type="timestamp" column="ACTIVE_DATE" />
    <property name="inactiveDate" type="timestamp" column="INACTIVE_DATE" />
    <property name="createDate" type="timestamp" column="CREATE_DATE" update="false" />
    <property name="createUser" type="string" column="CREATE_USER" update="false" />
    <property name="lastUpdate" type="timestamp" column="LAST_UPDATE" />
    <property name="lastUpdateUser" type="string" column="LAST_UPDATE_USER" />
</class>


Code:
public class Authorization extends BaseBean {
...
    private Set users;
    public Set getUsers() {
        return users;
    }
    public void setUsers(Set users) {
        this.users = users;
    }
...
}

public class User extends BaseBean {
...
    private Set auths;
    public Set getAuths() {
        return auths;
    }
    public void setAuths(Set auths) {
        this.auths = auths;
    }
...
}


Top
 Profile  
 
 Post subject: Re: find method for many-many relationship attempting update
PostPosted: Thu Sep 03, 2009 11:20 pm 
Newbie

Joined: Tue Apr 06, 2004 8:44 am
Posts: 9
Does anyone have any ideas on this? Looking at the stack trace, it appears as though it actually gets both colections for the many-to-many relationship but at the end it marks one of the objects as needing update ("1 update"). I think it does this when it flushes. I'm really stuck here...does anyone have any ideas about this?

Thanks,
Travis

Code:
...
22:07:10,975 DEBUG AbstractBatcher:426 - about to open ResultSet (open ResultSets: 0, globally: 0)
22:07:10,975 DEBUG Loader:1078 - result set contains (possibly empty) collection: [com.gtsyn.security.bean.Authorization.users#1]
22:07:10,976 DEBUG Loader:1197 - result row: EntityKey[com.gtsyn.security.bean.User#1]
22:07:10,976 DEBUG Loader:1008 - found row of collection: [com.gtsyn.security.bean.Authorization.users#1]
22:07:10,980 DEBUG AbstractBatcher:433 - about to close ResultSet (open ResultSets: 1, globally: 1)
22:07:10,981 DEBUG AbstractBatcher:418 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
22:07:10,981 DEBUG CollectionLoadContext:240 - 1 collections were found in result set for role: com.gtsyn.security.bean.Authorization.users
22:07:10,981 DEBUG CollectionLoadContext:283 - collection fully initialized: [com.gtsyn.security.bean.Authorization.users#1]
22:07:10,982 DEBUG CollectionLoadContext:249 - 1 collections initialized for role: com.gtsyn.security.bean.Authorization.users
22:07:10,982 DEBUG Loader:2031 - done loading collection
22:07:10,982 DEBUG ConnectionManager:325 - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
22:07:10,983 DEBUG HibernateTemplate:389 - Eagerly flushing Hibernate session
22:07:10,992 DEBUG AbstractFlushingEventListener:134 - processing flush-time cascades
22:07:10,995 DEBUG AbstractFlushingEventListener:177 - dirty checking collections
22:07:11,015 DEBUG Collections:199 - Collection found: [com.gtsyn.security.bean.User.auths#1], was: [com.gtsyn.security.bean.User.auths#1] (initialized)
22:07:11,023 DEBUG Collections:199 - Collection found: [com.gtsyn.security.bean.Authorization.users#1], was: [com.gtsyn.security.bean.Authorization.users#1] (initialized)
22:07:11,023 DEBUG AbstractFlushingEventListener:108 - Flushed: 0 insertions, 1 updates, 0 deletions to 2 objects
22:07:11,024 DEBUG AbstractFlushingEventListener:114 - Flushed: 0 (re)creations, 0 updates, 0 removals to 2 collections
22:07:11,026 DEBUG Printer:106 - listing entities:
22:07:11,028 DEBUG Printer:113 - com.gtsyn.security.bean.User{id=1, createUser=travep, auths=[com.gtsyn.security.bean.Authorization#1], lastUpdate=2009-08-27 22:31:05, activeDate=2009-08-27 22:31:05, lastUpdateUser=travep, userName=travep, inactiveDate=null, createDate=2009-08-27 22:31:05, password=password}
22:07:11,029 DEBUG Printer:113 - com.gtsyn.security.bean.Authorization{id=1, users=[com.gtsyn.security.bean.User#1], application=com.gtsyn.security.bean.Application#1, createUser=travep, lastUpdate=2009-08-27 22:31:05, description=Admin role for security application, authName=null, lastUpdateUser=travep, createDate=2009-08-27 22:31:05}
22:07:11,038 DEBUG AbstractBatcher:410 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
22:07:11,041 DEBUG SQL:111 -
....


Top
 Profile  
 
 Post subject: Re: find method for many-many relationship attempting update
PostPosted: Sat Sep 05, 2009 12:39 pm 
Newbie

Joined: Tue Apr 06, 2004 8:44 am
Posts: 9
I'm still stuck on this. At this point, all of my loads on this Authorization object have this error. I have commented out all of the joins on the mapping. At this point, it looks like this:

Code:
    <class name="Authorization" table="AUTHORIZATION">
        <id name="id" type="java.lang.Long">
            <column name="AUTH_ID" precision="18" scale="0" />
            <generator class="identity" />
        </id>
        <property name="authName" type="string" column="AUTH_NAME" />
        <property name="description" type="string" column="DESCRIPTION" />
        <property name="createDate" type="timestamp" column="CREATE_DATE" update="false" />
        <property name="createUser" type="string" column="CREATE_USER" update="false" />
        <property name="lastUpdate" type="timestamp" column="LAST_UPDATE" />
        <property name="lastUpdateUser" type="string" column="LAST_UPDATE_USER" />
    </class>


It is still a problem. Here's the stack trace. As you can see, it actually loads the data and then rather than quitting, it seems to find the collection of results dirty & find that it needs updating. At no point do I do any kind of update. I'm getting a little desperate with this one...does *anyone* have any ideas of something I could look at?

Code:
11:34:54,191 DEBUG DefaultListableBeanFactory:214 - Returning cached instance of singleton bean '/auth'
11:34:54,258 DEBUG SessionFactoryUtils:318 - Opening Hibernate Session
11:34:54,351 DEBUG SessionImpl:247 - opened session at timestamp: 12521684942
11:34:54,381 DEBUG AbstractBatcher:410 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
11:34:54,382 DEBUG ConnectionManager:444 - opening JDBC connection
11:34:54,389 DEBUG SQL:111 -
    /* criteria query */ select
        this_.AUTH_ID as AUTH1_7_0_,
        this_.AUTH_NAME as AUTH2_7_0_,
        this_.DESCRIPTION as DESCRIPT3_7_0_,
        this_.CREATE_DATE as CREATE4_7_0_,
        this_.CREATE_USER as CREATE5_7_0_,
        this_.LAST_UPDATE as LAST6_7_0_,
        this_.LAST_UPDATE_USER as LAST7_7_0_
    from
        AUTHORIZATION this_
Hibernate:
    /* criteria query */ select
        this_.AUTH_ID as AUTH1_7_0_,
        this_.AUTH_NAME as AUTH2_7_0_,
        this_.DESCRIPTION as DESCRIPT3_7_0_,
        this_.CREATE_DATE as CREATE4_7_0_,
        this_.CREATE_USER as CREATE5_7_0_,
        this_.LAST_UPDATE as LAST6_7_0_,
        this_.LAST_UPDATE_USER as LAST7_7_0_
    from
        AUTHORIZATION this_
11:34:54,421 DEBUG AbstractBatcher:426 - about to open ResultSet (open ResultSets: 0, globally: 0)
11:34:54,424 DEBUG Loader:1197 - result row: EntityKey[com.gtsyn.security.bean.Authorization#1]
11:34:54,451 DEBUG AbstractBatcher:433 - about to close ResultSet (open ResultSets: 1, globally: 1)
11:34:54,451 DEBUG AbstractBatcher:418 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
11:34:54,454 DEBUG TwoPhaseLoad:130 - resolving associations for [com.gtsyn.security.bean.Authorization#1]
11:34:54,458 DEBUG TwoPhaseLoad:226 - done materializing entity [com.gtsyn.security.bean.Authorization#1]
11:34:54,458 DEBUG StatefulPersistenceContext:860 - initializing non-lazy collections
11:34:54,461 DEBUG DistinctResultTransformer:96 - transformed: 1 rows to: 1 distinct results
11:34:54,461 DEBUG ConnectionManager:325 - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
11:34:54,464 DEBUG HibernateTemplate:389 - Eagerly flushing Hibernate session
11:34:54,473 DEBUG AbstractFlushingEventListener:134 - processing flush-time cascades
11:34:54,476 DEBUG AbstractFlushingEventListener:177 - dirty checking collections
11:34:54,485 DEBUG AbstractFlushingEventListener:108 - Flushed: 0 insertions, 1 updates, 0 deletions to 1 objects
11:34:54,486 DEBUG AbstractFlushingEventListener:114 - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
11:34:54,488 DEBUG Printer:106 - listing entities:
11:34:54,488 DEBUG Printer:113 - com.gtsyn.security.bean.Authorization{id=1, createUser=travep, lastUpdate=2009-08-27 22:31:05, description=Admin role for security application, authName=null, lastUpdateUser=travep, createDate=2009-08-27 22:31:05}
11:34:54,495 DEBUG AbstractBatcher:410 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
11:34:54,496 DEBUG SQL:111 -
    /* update
        com.gtsyn.security.bean.Authorization */ update
            AUTHORIZATION
        set
            AUTH_NAME=?,
            DESCRIPTION=?,
            LAST_UPDATE=?,
            LAST_UPDATE_USER=?
        where
            AUTH_ID=?
Hibernate:
    /* update
        com.gtsyn.security.bean.Authorization */ update
            AUTHORIZATION
        set
            AUTH_NAME=?,
            DESCRIPTION=?,
            LAST_UPDATE=?,
            LAST_UPDATE_USER=?
        where
            AUTH_ID=?
11:34:54,510 DEBUG AbstractBatcher:66 - Executing batch size: 1
11:34:54,531 DEBUG AbstractBatcher:418 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
11:34:54,537 DEBUG JDBCExceptionReporter:92 - Could not execute JDBC batch update [/* update com.gtsyn.security.bean.Authorization */ update AUTHORIZATION set AUTH_NAME=?, DESCRIPTION=?, LAST_UPDATE=?, LAST_UPDATE_USER=? where AUTH_ID=?]
java.sql.BatchUpdateException: Column 'auth_name' cannot be null
   at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1693)
   at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1108)
   at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:297)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
   at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:266)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.