openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From plins...@gmail.com
Subject Re: Bulk Update
Date Mon, 03 Dec 2007 22:46:53 GMT
Hi,

A couple of guesses:

- have you already modified anything in the transaction before calling
executeUpdate()? This could trigger OpenJPA to do the update in memory
in some situations, which would explain the SELECT.

- I think that the sadly-unlocalized message is caused by your attempt
to update the calendar field. I don't know if this is a spec
limitation or a product problem.

- recently, a few limitations around use of parameters in bulk updates
were resolved. I don't remember the details of the issue, but just
bear in mind that there are differences in the latest 1.1.0 snapshots
compared to 1.0 or older snapshots.

- it looks like you are using the bulk update facilities to update
just a single record (since you're using an id comparison in the WHERE
clause.  Is this the case? Typically, bulk updates are best used when
updating many records, not just a single record.

-Patrick

-Patrick

On 12/3/07, Bruce Beaumont <bruce.beaumont@ucs-solutions.co.za> wrote:
> Hi
>
> I have a bean with the following mapping
> @Id
> @Column(name="s_id", nullable=false)
> private long id = 0;
>
> @Basic
> @Column(name="s_key", length=10, nullable=true)
> private String key = null;
>
> @Basic
> @Column(name="s_desc", length=30, nullable=true)
> private String description = null;
>
> @Basic
> @Column(name="s_decimal", scale=14, precision=2, nullable=true)
> public BigDecimal dec = null;
>
> @Basic
> @Column(name="s_date", nullable=true)
> public Calendar date = null;
>
> @Basic
> @Column(name="s_dt", nullable=true)
> public Calendar dt = null;
>
> and am trying to do a bulk update as follows
>
> Query q = em.createQuery("update simple x set x.description = ?1, x.dec
> = ?2, x.date = ?3 where x.id = ?4");
> q.setParameter(1, "Test 123");
> q.setParameter(2, new BigDecimal("1234.56"));
> q.setParameter(3, Calendar.getInstance());
> q.setParameter(4, 2l);
>
> I get the following error:
> 35  BRUCE-DEV  INFO   [main] openjpa.Runtime - Starting OpenJPA 1.0.1
> 167  BRUCE-DEV  INFO   [main] openjpa.jdbc.JDBC - Using dictionary class
> "org.apache.openjpa.jdbc.sql.InformixDictionary".
> 1344  BRUCE-DEV  TRACE  [main] openjpa.jdbc.SQL - <t 13359904, conn
> 27211574> executing prepstmnt 8499707 SELECT t0.s_id, t0.s_date,
> t0.s_decimal, t0.s_desc, t0.s_dt, t0.s_key FROM simple t0 WHERE (t0.s_id
> = ?) [params=(long) 2]
> 1346  BRUCE-DEV  TRACE  [main] openjpa.jdbc.SQL - <t 13359904, conn
> 27211574> [1 ms] spent
> Exception in thread "main" <openjpa-1.0.1-r420667:592145 nonfatal user
> error> org.apache.openjpa.persistence.ArgumentException:
> only-update-primitives
> 	at
> org.apache.openjpa.kernel.QueryImpl.updateInMemory(QueryImpl.java:1149)
> 	at
> org.apache.openjpa.kernel.QueryImpl.updateInMemory(QueryImpl.java:1051)
> 	at org.apache.openjpa.kernel.ExpressionStoreQuery
> $DataStoreExecutor.executeUpdate(ExpressionStoreQuery.java:692)
> 	at org.apache.openjpa.kernel.QueryImpl.update(QueryImpl.java:1039)
> 	at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:803)
> 	at org.apache.openjpa.kernel.QueryImpl.updateAll(QueryImpl.java:878)
> 	at
> org.apache.openjpa.kernel.DelegatingQuery.updateAll(DelegatingQuery.java:573)
> 	at
> org.apache.openjpa.persistence.QueryImpl.executeUpdate(QueryImpl.java:319)
> 	at openjpa.TestUpd.run(TestUpd.java:42)
> 	at openjpa.TestUpd.main(TestUpd.java:57)
>
> The strange thing is that if I remove the where clause it works OK. If I
> use a fetch and change the bean values it works as well.
>
> Could anyone please give an indication for this error.
>
> Bruce
>
> PS: The select indicated in the trace is also a bit odd as it is not in
> my small test program and I do not understand why it is there. It is not
> there if there is no where clause.
>
>


-- 
Patrick Linskey
202 669 5907

Mime
View raw message