You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Derek Hardy <de...@teknosys.co.uk> on 2003/06/11 11:50:22 UTC

Adding new columns

Hi

I've recently added a new column to an existing table and regenerated the
classes.

If then use the column in my code, it doesn't seem to populate/update the
value within the database.

Do I need to do something else when adding new columns to existing Torque
structures?

Thanks

Derek

RE: Adding new columns

Posted by Derek Hardy <de...@teknosys.co.uk>.
Hi Eric

This is the only column that isn't being saved, but it's not the only date
column in the table.

The java code is as follows :-

.
.
.
    try {
      Property p = new Property();

      if (UsefulFunctions.toInt(f.getPropertyId()) != 0) {
        Criteria c = new Criteria();
        c.add(PropertyPeer.PROPERTY_ID, f.getPropertyId());

        List v = PropertyPeer.doSelect(c);

        if (v.size() > 0) {
          p = (Property) v.get(0);
        }
      }
      else {
        p.setStatusCode(f.getStatusCode());
        p.setDatePosted(new java.util.Date(System.currentTimeMillis()));
        p.setStatusChangeDate(new
java.util.Date(System.currentTimeMillis()));
      }

      p.setCategoryId(f.getCategoryId());
      p.setContact(f.getContact());
      p.setDateFound(UsefulFunctions.stringToDate(f.getDateFound()));
      p.setDescription(f.getDescription());
      p.setHighlightItem(f.getHighlightItem());
      p.setPropertyName(f.getPropertyName());
      p.setPropertyRef(f.getPropertyRef());
      p.setStoreId(f.getStoreId());
      p.setTelephone(f.getTelephone());

      if (!f.getStatusCode().equals(f.getOldStatusCode())) {
        p.setStatusCode(f.getStatusCode());

        p.setStatusChangeDate(new
java.util.Date(System.currentTimeMillis()));
      }


      p.save();
    }
.
.
.

I've got Torque set to debug, but it doesn't output the update statements in
any detail, just the select statements, but I'll take a look at p6spy.

Thanks

Derek


Re: Adding new columns

Posted by Eric Emminger <er...@ericemminger.com>.
Derek

Derek Hardy wrote:
> I've added the column status_change_date and have definately set it's value
> in my java code. However when the data is written to the MySQL database
> there isn't any value in that column.

Is this the only column that's not saving to the database? It could be 
an issue with how MySQL handles dates.

Can you provide a snip of your Java code?

Can you log the SQL statements Torque is sending to MySQL? I'd suggest 
using p6spy (during runtime only) to examine the SQL Torque is sending.

http://p6spy.com/

Eric


RE: Adding new columns

Posted by Derek Hardy <de...@teknosys.co.uk>.
Eric

This is an extract from the schema.xml file, is this what you meant?

	<table name="Property" javaName="Property">
		<column name="property_id" type="INTEGER" size="10" primaryKey="true"
required="true" autoIncrement="true"/>
		<column name="status_code" type="INTEGER" size="2" required="true"/>
		<column name="status_change_date" type="DATE" required="true" />
		<column name="store_id" type="INTEGER" size="10" required="true"/>
		<column name="category_id" type="INTEGER" size="10" required="true"/>
		<column name="property_ref" type="VARCHAR" size="20" required="true"/>
		<column name="date_found" type="DATE" required="true"/>
		<column name="date_posted" type="DATE" required="true"/>
		<column name="property_name" type="VARCHAR" size="60" required="true"/>
		<column name="contact" type="VARCHAR" size="50"/>
		<column name="telephone" type="VARCHAR" size="30"/>
		<column name="manufacturer" type="VARCHAR" size="60" required="true"/>
		<column name="colour" type="VARCHAR" size="60"/>
		<column name="description" type="CLOB"/>
		<column name="distinguishing_features" type="CLOB"/>
		<column name="highlight_item" type="CHAR" size="1"/>
		<foreign-key foreignTable="Property_Status_Codes">
			<reference local="status_code" foreign="status_code"/>
		</foreign-key>
		<foreign-key foreignTable="Property_Stores">
			<reference local="store_id" foreign="store_id"/>
		</foreign-key>
		<foreign-key foreignTable="Property_Categories">
			<reference local="category_id" foreign="category_id"/>
		</foreign-key>
	</table>

I've added the column status_change_date and have definately set it's value
in my java code. However when the data is written to the MySQL database
there isn't any value in that column.

I'm populating it like this,

prop.setStatusChangeDate(new java.util.Date(System.currentTimeMillis()));

Then initiating the update, using the save() method.

I've tried retrieving the record first, and forcing the update without
retrieving the record using the setNew(false) method.

Thanks

Derek

-----Original Message-----
From: Eric Emminger [mailto:eric@ericemminger.com]
Sent: 11 June 2003 14:49
To: Turbine Torque Users List
Subject: Re: Adding new columns


Derek

Derek Hardy wrote:
> Hi
>
> I've recently added a new column to an existing table and regenerated the
> classes.
>
> If then use the column in my code, it doesn't seem to populate/update the
> value within the database.
>
> Do I need to do something else when adding new columns to existing Torque
> structures?

Should work. Can you provide the relevant part of your schema.xml file?

Eric


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: Adding new columns

Posted by Eric Emminger <er...@ericemminger.com>.
Derek

Derek Hardy wrote:
> Hi
> 
> I've recently added a new column to an existing table and regenerated the
> classes.
> 
> If then use the column in my code, it doesn't seem to populate/update the
> value within the database.
> 
> Do I need to do something else when adding new columns to existing Torque
> structures?

Should work. Can you provide the relevant part of your schema.xml file?

Eric