Hello,

I have a class like:

class Workstation {
  int workstationID
  String workstationName
...
}

The workstation attribute is the primary key (autoincrement=true).

I want to enter the workstationName and retrieve the corresponding entry.
If I try this:
----code
Workstation workstation = new Workstation();
workstation.setWorkstationName("Test");

Query query = new QueryByExample(workstation);
try {
broker.beginTransaction();
Workstation toBeEdited = (Workstation) broker.getObjectByQuery(query);
broker.commitTransaction();
} catch (Throwable t) {
broker.abortTransaction();
t.printStackTrace();
}
----code

This code doesn't work because OJB create a new primary key for this instance and try 
to find it in the database. Of course it doesn't find it and the query return a null 
value.

It seems that the only way to retrieve one entry is by the workstationID.
Is it right?
Is there other method to do this?

Thank you
Sylvain

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

Reply via email to