openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sutter" <kwsut...@gmail.com>
Subject Re: UPDATE is called when only SELECT is expected
Date Tue, 30 Sep 2008 21:11:58 GMT
I believe this issue is already being discussed on this forum:

http://n2.nabble.com/Non-dirty-entity-version-field-update-SUPER-URGENT!!!-td1120307.html#a1129303

Please join that discussion with any additional insights.

Thanks,
Kevin

On Tue, Sep 30, 2008 at 2:50 PM, Sergej Shafarenka <sergej@beworx.com>wrote:

> Hey Guys!
>
> I use OpenJPA in tandem with SpringFramework. I wrote a simple application
> which reads some data from MySQL database and faced very weird problem:
> openjpa executes an "update" statement when only "select" query is used and
> no object modifications are done.
>
> // My service's method looks like this one
> @Transactional(readOnly=true)
> public void test(String user) {
>        Query query = m_entityManager.createQuery("select u from User u");
>        List<User> users = (List<User>) query.getResultList();
>        for (User u : users) {
>                if (u.getLoginName().equals(user)) {
>                        System.out.println("Bingo!");
>                }
>        }
> }
>
> // User class is very simple
> @Entity
> @Table(name="user")
> public class User implements Serializable {
>        @Id
>        @Column(name="user_id")
>        private int m_id;
>
>        @Column(name="user_login_name")
>        private String m_loginName;
>
>        // getters and setters are omitted as not essential for problem
> understanding
> }
>
> // and openjpa's log-output looks like the one below
> openjpa.jdbc.SQL - <t 6533862, conn 16102116> executing prepstmnt 16900472
> SELECT t0.user_id, t0.user_login_name from t0
> openjpa.jdbc.SQL - <t 6533862, conn 16102116> [0 ms] spent
> // and this is the problem :(((
> openjpa.jdbc.SQL - <t 6533862, conn 16102116> executing prepstmnt 25980092
> UPDATE user SET user_login_name = ? WHERE user_id = ? [params=(String) test,
> (int) 1]
> openjpa.jdbc.SQL - <t 6533862, conn 16102116> [0 ms] spent
>
>
> It is already three days I spent on fixing the problem with no success :(
> Would someone help me please. I am even ready to switch off automatic update
> functionality if there were such possibility.
>
> Thanks and best regards,
> Sergej
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message