aspose file tools*
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
Author

OJB findByTemplate Problem

Bob Harrison
Greenhorn

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="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl">
<attribute attribute-name="autoNaming" attribute-value="false" />
<attribute attribute-name="seq.incrementBy" attribute-value="1" />
<attribute attribute-name="seq.minValue" attribute-value="1" />
</sequence-manager>
<class-descriptor class="com.bb.userdata.UserVO" 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" />
<collection-descriptor
name="weight"
element-class-ref="com.bb.userdata.WeightVO"
orderby="weight_date"
sort="DESC"
auto-retrieve="true"
auto-update="true"
auto-delete="true">
<inverse-foreignkey field-ref="userNum" />
</collection-descriptor>
</class-descriptor>

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 org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl -createPool was called
2006-04-18 18:53:13,585 {http-8080-Processor25} DEBUG org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl -makeObject called
2006-04-18 18:53:15,743 {http-8080-Processor25} DEBUG org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl -Create new connection using DriverManager: org.postgresql.jdbc2.Jdbc2Connection@3744bc
2006-04-18 18:53:15,759 {http-8080-Processor25} DEBUG org.apache.ojb.broker.accesslayer.ConnectionManagerImpl -Request new connection from ConnectionFactory: org.postgresql.jdbc2.Jdbc2Connection@3744bc
2006-04-18 18:53:16,025 {http-8080-Processor25} DEBUG org.apache.ojb.broker.accesslayer.JdbcAccessImpl -executeQuery: SELECT A0.password,A0.initial_weight,A0.user_num,A0.credit_auth,A0.lesson_num,A0.transaction_xid,A0.sex,A0.height,A0.target_weight,A0.dob,A0.email,A0.screen_name,A0.start_date,A0.exp_date FROM users A0 WHERE (((((A0.password = d) AND A0.email = d@d.com) 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 org.apache.ojb.broker.accesslayer.RsIterator -RsIterator[org.apache.ojb.broker.accesslayer.RsQueryObject[query: QueryByCriteria from class com.beeslender.userdata.UserVO where [passwordOne = d, emailOne = d@d.com, 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 org.apache.ojb.broker.accesslayer.RsIterator -hasNext() -> false
2006-04-18 18:53:16,366 {http-8080-Processor25} DEBUG org.apache.ojb.broker.core.PersistenceBrokerImpl -PB.close was called: org.apache.ojb.broker.core.PersistenceBrokerImpl@935741

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
 
jQuery in Action, 2nd edition
 
subject: OJB findByTemplate Problem