Hello list,
I've 2 tables

CREATE TABLE c_account(
  account_id            INTEGER          DEFAULT 0 NOT NULL,
  login                 VARCHAR(100),
  password              VARCHAR(100),
  PRIMARY KEY (account_id)
)
;

CREATE TABLE fem_employee(
  account_id    INTEGER     DEFAULT 0 NOT NULL,
  first_name            VARCHAR(100),
  last_name             VARCHAR(100),
  PRIMARY KEY (account_id)
)
;


I want to implement the "mapping each class on a distinct table" as in tutorial3 so I write
the descriptor:


<class-descriptor class="allibo.core.Account" table="c_account"> <field-descriptor name="account_id" column="account_id" jdbc-type="INTEGER" primarykey="true" autoincrement="true"/>
<field-descriptor name="login" column="login" jdbc-type="VARCHAR"/>
<field-descriptor name="password" column="password" jdbc-type="VARCHAR"/>
</class-descriptor>


<class-descriptor class="allibo.commerce.Employee" table="fem_employee">
<field-descriptor name="account_id" column="account_id" jdbc-type="INTEGER" primarykey="true" autoincrement="true"/> <field-descriptor name="first_name" column="login" jdbc-type="VARCHAR"/>
<field-descriptor name="last_name" column="password" jdbc-type="VARCHAR"/>
<reference-descriptor name="super" class-ref="allibo.core.Account" auto-retrieve="true" auto-update="true" auto-delete="true">
<foreignkey field-ref="account_id"/>
</reference-descriptor> </class-descriptor>


implemented by the classes

public class Account {
  private int account_id;
  private String login;
  private String password;
  /* setter and getter methods*/
}
public class Employee extends Account {
  private String first_name;
  private String last_name
  /* setter and getter methods*/
}

OK this is the situation. Now the questions:
When I try to add a new Employee no problem, a row is added to the c_account and fem_employee.
The problem is when I try to delete an Employee:
employee = new Employee();
employee.setAccount_id(employee_id);
Criteria crit = new Criteria();
crit.addEqualTo("account_id" , new Integer(employee_id));
Query query = new QueryByCriteria(employee);
try {
broker.beginTransaction();
broker.delete(employee);
broker.commitTransaction();
} catch (PersistenceBrokerException ex) {
broker.abortTransaction();
System.out.println(ex.getMessage());
ex.printStackTrace();
}
this affect only the fem_employee and not c_account. Is this correct?
In the tutorial3 is written about "mapping each class on a distinct table":
"This is the most simple solution. Just write a complete ClassDescriptor for each class that contains FieldDescriptors for all (also inherited) attributes."
From my point of view this means that my descriptor is wrong and should be:


<class-descriptor class="allibo.commerce.Employee" table="fem_employee">
<field-descriptor name="account_id" column="account_id" jdbc-type="INTEGER" primarykey="true" autoincrement="true"/> <field-descriptor name="first_name" column="login" jdbc-type="VARCHAR"/>
<field-descriptor name="last_name" column="password" jdbc-type="VARCHAR"/>
<field-descriptor name="login" column="login" jdbc-type="VARCHAR"/>
<field-descriptor name="password" column="password" jdbc-type="VARCHAR"/>
<reference-descriptor name="super" class-ref="allibo.core.Account" auto-retrieve="true" auto-update="true" auto-delete="true">
<foreignkey field-ref="account_id"/>
</reference-descriptor> </class-descriptor>


but in this case, when I try to insert an Employee, I've
java.sql.SQLException: Column not found, message from server: "Unknown column 'first_name' in 'field list'"
What is wrong?


Thank you



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to