File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes OJB findByTemplate Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "OJB findByTemplate Problem" Watch "OJB findByTemplate Problem" New topic

OJB findByTemplate Problem

Bob Harrison

Joined: Apr 18, 2006
Posts: 12
I'm developing in Eclipse 3.1.2 with the Tomcat (3.1.0) and OJB (3.01.) plugins.

I've got a value object with the following:
private Integer userNum;
private String screenName;
private String passwordOne;
private String emailOne;
private String sex;
private java.sql.Date birthDate;
private float initialWeight;
private float height;
private float targetWeight;
private java.sql.Date expDate;
private java.sql.Date startDate;
private String transactionXID;
private String creditAuth;
private long lessonNum;
public Vector weight = new Vector(); // of type WeightVO
There are get/set methods for all.

The mapping in repository.xml (to PostgreSQL 8.0) is:
<jdbc-connection-descriptor jcd-alias="default" platform="PostgreSQL" default-connection="true" jdbc-level="2.0" driver="org.postgresql.Driver" protocol="jdbc" subprotocol="postgresql" dbalias="bb" username="" password="" eager-release="false"
batch-mode="false" useAutoCommit="1" ignoreAutoCommitExceptions="false">
<sequence-manager className="">
<attribute attribute-name="autoNaming" attribute-value="false" />
<attribute attribute-name="seq.incrementBy" attribute-value="1" />
<attribute attribute-name="seq.minValue" attribute-value="1" />
<class-descriptor class="" table="users">
<field-descriptor name="userNum" column="user_num" jdbc-type="INTEGER" primarykey="true" autoincrement="true" sequence-name="users_seq" />
<field-descriptor name="screenName" column="screen_name" jdbc-type="VARCHAR" />
<field-descriptor name="passwordOne" column="password" jdbc-type="VARCHAR" />
<field-descriptor name="emailOne" column="email" jdbc-type="VARCHAR" />
<field-descriptor name="sex" column="sex" jdbc-type="CHAR" />
<field-descriptor name="birthDate" column="dob" jdbc-type="DATE" />
<field-descriptor name="initialWeight" column="initial_weight" jdbc-type="REAL" />
<field-descriptor name="height" column="height" jdbc-type="REAL" />
<field-descriptor name="targetWeight" column="target_weight" jdbc-type="REAL" />
<field-descriptor name="expDate" column="exp_date" jdbc-type="DATE" />
<field-descriptor name="startDate" column="start_date" jdbc-type="DATE" />
<field-descriptor name="transactionXID" column="transaction_xid" jdbc-type="VARCHAR" />
<field-descriptor name="creditAuth" column="credit_auth" jdbc-type="VARCHAR" />
<field-descriptor name="lessonNum" column="lesson_num" jdbc-type="INTEGER" />
<inverse-foreignkey field-ref="userNum" />

My problem is that I cannot populate the value object with the email/password combination and find the entry in the database. I have used the findByTemplate methods in the OJB tutorial.

debug shows this:
2006-04-18 18:53:13,491 {http-8080-Processor25} DEBUG -createPool was called
2006-04-18 18:53:13,585 {http-8080-Processor25} DEBUG -makeObject called
2006-04-18 18:53:15,743 {http-8080-Processor25} DEBUG -Create new connection using DriverManager: org.postgresql.jdbc2.Jdbc2Connection@3744bc
2006-04-18 18:53:15,759 {http-8080-Processor25} DEBUG -Request new connection from ConnectionFactory: org.postgresql.jdbc2.Jdbc2Connection@3744bc
2006-04-18 18:53:16,025 {http-8080-Processor25} DEBUG -executeQuery: SELECT A0.password,A0.initial_weight,A0.user_num,A0.credit_auth,A0.lesson_num,A0.transaction_xid,,A0.height,A0.target_weight,A0.dob,,A0.screen_name,A0.start_date,A0.exp_date FROM users A0 WHERE (((((A0.password = d) AND = AND A0.initial_weight = 0.0) AND A0.height = 0.0) AND A0.target_weight = 0.0) AND A0.lesson_num = 0
2006-04-18 18:53:16,334 {http-8080-Processor25} DEBUG -RsIterator[[query: QueryByCriteria from class com.beeslender.userdata.UserVO where [passwordOne = d, emailOne =, initialWeight = 0.0, height = 0.0, targetWeight = 0.0, lessonNum = 0], class descriptor: com.beeslender.userdata.UserVO]] initialized
2006-04-18 18:53:16,358 {http-8080-Processor25} DEBUG -hasNext() -> false
2006-04-18 18:53:16,366 {http-8080-Processor25} DEBUG -PB.close was called:

I've read the Howto and Tutorial, Googled for the past several hours and can't find what I'm doing wrong. Can anyone give me a little guidance?

Much Appreciated,
Bob Harrison

"In theory there is no difference between theory and practice. In practice there is."<br />Yogi Berra
I agree. Here's the link:
subject: OJB findByTemplate Problem
It's not a secret anymore!