openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruce Beaumont <bruce.beaum...@ucs-solutions.co.za>
Subject Bulk Update
Date Mon, 03 Dec 2007 12:57:59 GMT
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.


Mime
View raw message