Armin Waibel wrote:

Hi Jean-Yves,

jys wrote:

I'am getting trouble retrieving an instance of a class representing a tree structure with ojb (last release), in the database the record is good :

parentid id name description hJ}Tfk7o>#S[Om?\AP:X}T1y hJ}Tfk7o>#S[Om?\AP:X}T1y terre <NULL> hJ}Tfk7o>#S[Om?\AP:X}T1y OK?`L_igc>JlU:m66mH^",@: france <NULL> OK?`L_igc>JlU:m66mH^",@: (ZjHVf">aQvtj%6H)$NC$7hl paris <NULL> (ZjHVf">aQvtj%6H)$NC$7hl )f[u|G'za6-&!P]OUlp-=z>n toureiffel <NULL> (ZjHVf">aQvtj%6H)$NC$7hl Wz:YyW,[EMAIL PROTECTED];A bnf <NULL> Wz:YyW,[EMAIL PROTECTED];A BWZ[_/i>Oq{Kj48VXBPOe.~& salle1 <NULL> So OJB was able to persists it right.

But whem i'am trying to retrieve the structure, it's kind of messed up, as "terre" wich is the root of the tree is the child of itself, like that :

terre
    terre france
    ......


Could you describe what's going wrong, does OJB throw an exception or do you get a StackOverflowError?

I assume it can result in a StackOverflowError, because by default the retrieve of the 1:1 reference is enabled and the 'root' object lookup it's parent --> root, this itself will lookup the parent --> root ...
Could this be the problem?

I did a test with latest from CVS (OJB_1_0_RELEASE branch) setting a object as parent object of itself. This test pass.


You're right it was the problem, just because has i set my root parent to itself, it went back from OJB has a child of itself, the solution was to set the root parent to null, this way i have to discard my not nullable constaint on the parentid colum so it's not perfect but it's working. The problem was not an exception being throwed but just the root being a child of itself.



I don't know what i'am doing bad, but i tried to secure my getter and setters so it's not possible to add a child which is the same object. I was surprised to not get an exception, so i tried to add breakpoints to all my getters and setters to see when OJB is calling them, but it never stop at my breakpoints. So how does OJB set the attributes of the instances (my instances attributes are private) ? i really don't get it.


This depends on the 'PersistentFieldClass' setting in OJB.properties file. Per default OJB directly set the attributes of your persistent objects. http://db.apache.org/ojb/docu/guides/advanced-technique.html#Change+PersistentField+Class

That's really interesting, i do not knew that it was possible to bypass private accessors like that, for those who are interested :

http://radio.javaranch.com/val/2004/05/18/1084891793000.html



> It's another unrelated question but i always get this error when
> starting my tests : is it normal ?
>
> org.apache.ojb.broker.platforms.PlatformPostgresImpl
> java.lang.ClassNotFoundException:
> org.apache.ojb.broker.platforms.PlatformPostgresImpl
>    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>    at java.security.AccessController.doPrivileged(Native Method)
>    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
>    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
>    at java.lang.Class.forName0(Native Method)
>    at java.lang.Class.forName(Class.java:242)
>    at org.apache.ojb.broker.util.ClassHelper.getClass(Unknown Source)
>    at org.apache.ojb.broker.util.ClassHelper.getClass(Unknown Source)
>    at
> org.apache.ojb.broker.platforms.PlatformFactory.getPlatformFor(Unknown

Seems you specify a wrong 'platform' name in your jdbc-connection-descriptor
> org.apache.ojb.broker.platforms.PlatformPostgresImpl
admittedly this class doesn't exist in OJB (the correct name is PlatformPostgreSQLImpl). How did you set the platform attribute? The allowed settings can be found here:
http://db.apache.org/ojb/docu/guides/repository.html#Attributes-N1013A

Example:
<jdbc-connection-descriptor
  jcd-alias="default"
  default-connection="true"
  platform="PostgreSQL"
  jdbc-level="2.0"
...

regards,
Armin

Thanks for your precious help.

Jean-Yves

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

Reply via email to