Hi, ow wrote:
JDK1.3 / Sybase 12.5The problem you encounter is not an OJB bug, as OJB uses the java beans mechanisms to detect property getters and setters implicitely .
Somehow, I was under impression that if I declare a class Test that has
someProperty of type int (see below) then OJB will be able to retrieve
object and set the 'int' type property without much work. That,
however, results in the following error:
[DEFAULT] ERROR: Error in operation [set] of object
[PersistentFieldPropertyImpl], getWriteMethod returned null
[DEFAULT] ERROR: Declaring class [Test]
[DEFAULT] ERROR: Property Name [someProperty]
[DEFAULT] ERROR: Property Type [int]
[DEFAULT] ERROR: anObject was class [Test]
[DEFAULT] ERROR: aValue was class [java.lang.Integer]
org.apache.ojb.broker.PersistenceBrokerException: getWriteMethod
returned null
If you do not like it you can
1. write a bean info class that declares the property getters and setters explicitely
2. tell OJB to use PersistentFieldDefaultImpl instead of PersistentFieldPropertyImpl in OJB.properties. OJB will then use Java reflection to access attributes instead of java beans lookup.
You have to tell OJB to use a FieldConversion to make this happen. You have to declare it in the field-descriptor in the repository_user.xml.I also thought that if boolean type is stored in the db as int, that conversion would be handled automatically. However that does not happen, istead "java.lang.IllegalArgumentException: argument type mismatch" is raised.
See jdbc-types.html and repository.html for details.
cheers,
Thomas
Any ideas? Thanks in advance
-----------------------------------------
pubic class Test {
�
private int someProperty;
�
public Test() {
}
...
public int getSomeProperty() {
return someProperty;
}
public void setSomeProperty(int someProperty) {
this.someProperty = someProperty;
}
/* ------------
it appears that OJB wants the method below instead of the one above,
otherwise the following error is raised
public void setSomeProperty(Integer someProperty) {
this.someProperty = someProperty.intValue();
}
------------ */
}
-----------------------------------------
Repository.xml is as follows:
<jdbc-connection-descriptor
platform="Sybase"
jdbc-level="2.0"
driver="com.sybase.jdbc2.jdbc.SybDriver"
protocol="..."
...
/>
-----------------------------------------
Repository_user.xml is as follows:
<class-descriptor
class="Test"
table="test">
<field-descriptor id="1"
name="id"
column="test_id"
jdbc-type="INTEGER"
primarykey="true"
autoincrement="false"
/>
<field-descriptor id="2"
name="someProperty"
column="some_property"
jdbc-type="INTEGER"
/>
...
</class-descriptor>
__________________________________________________
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.com/
--
To unsubscribe, e-mail: <mailto:ojb-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>
-- To unsubscribe, e-mail: <mailto:ojb-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>
