cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gentry, Michael \(Contractor\)" <>
Subject RE: UpdateQuery not updating
Date Wed, 05 Apr 2006 22:21:15 GMT
I've never used UpdateQuery before, but try:

UpdateQuery updated =
  new UpdateQuery(Customer.class,

Also, I don't think you need the commitChanges() at the end ...  That
would be more useful if you were working with actual CayenneDataObjects,
which you aren't.  Also, I think your object graph might get out-of-sync
this way, which could lead to more problems.


-----Original Message-----
From: Alan Baltazar [] 
Sent: Wednesday, April 05, 2006 5:13 PM
Subject: UpdateQuery not updating


  I'm trying to update a field in a table using the UpdateQuery. The
following code
doesn't update my data.

Date dob = null;
DateFormat df = DateFormat.getDateInstance();
DataContext ctxt =

String customerName = request.getParameter("customerName");
String dateOfBirth = request.getParameter("dateOfBirth");
Expression template = Expression.fromString("customerName =
Map params = new HashMap();
params.put("customerName", customerName);

UpdateQuery updated = new UpdateQuery(Customer.class,template);    
try { 
   dob = df.parse(dateOfBirth);        	
catch(ParseException e) {
   System.out.println("Unable to parse ");

return mapping.findForward("success");

this is the mysql table,
  `CUSTOMER_ID` int(10) unsigned NOT NULL ,
  `CUSTOMER_NAME` varchar(20) NOT NULL default '',
  `DATE_OF_BIRTH` date NOT NULL default '0000-00-00',
) TYPE=InnoDB;

here's the data object,
public class _Customer extends org.objectstyle.cayenne.CayenneDataObject

    public static final String CUSTOMER_NAME_PROPERTY = "customerName";
    public static final String DATE_OF_BIRTH_PROPERTY = "dateOfBirth";
    public static final String PRODUCT_ARRAY_PROPERTY = "productArray";

    public static final String CUSTOMER_ID_PK_COLUMN = "CUSTOMER_ID";

    public void setCustomerName(String customerName) {
        writeProperty("customerName", customerName);
    public String getCustomerName() {
        return (String)readProperty("customerName");
    public void setDateOfBirth(java.util.Date dateOfBirth) {
        writeProperty("dateOfBirth", dateOfBirth);
    public java.util.Date getDateOfBirth() {
        return (java.util.Date)readProperty("dateOfBirth");
    public void addToProductArray(dao.Product obj) {
        addToManyTarget("productArray", obj, true);
    public void removeFromProductArray(dao.Product obj) {
        removeToManyTarget("productArray", obj, true);
    public List getProductArray() {
        return (List)readProperty("productArray");

  if there's any other shorter way to do this with UpdateQuery, I'm

thanks for any help,

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

View raw message