Re: very, very serious problem - null values where objects should be

From: Marcin Skladaniec (poldwusmoko..mail.com)
Date: Mon Jun 05 2006 - 05:55:59 EDT

  • Next message: Tomi NA: "Re: very, very serious problem - null values where objects should be"

    Hi.
    Does the reverse relationship work ?

    Try isolating the bug from GUI and other parts of your code and see
    if it persists.

    Regards
    Marcin

    On 05/06/2006, at 7:33 PM, Tomi NA wrote:

    > I see very disturbing behaviour and while I'm not certain cayenne is
    > to blame, maybe someone could shed a little light on the subject.
    > First of all, I'm using 1.2RC1 - inherited the .xml files from
    > previous versions of 1.2.
    >
    > I experience what appears to be random null objects in the object
    > graph. At the moment, I'm debugging the app and am looking at the
    > following one-to-many relationship...
    > I have an object myObject whose getToObjectCategory() method should
    > give me the category of myObject - the method returns null.
    > In the database (pgsql 8.1.3), I can see that the category is intact -
    > no problem there. Looking at the myObject state, I can see that it's
    > persistenceState is set to 3 - so this is not a modification that
    > happened in memory - I believe the state would be 4 in that case.
    > What's more, I have a drop-down menu in the GUI where the seemingly
    > missing object category is present.
    >
    > A bit of information about my envinomnent...
    > I'm the only user connected to the database, my app is the only app
    > accessing the data and no (intentional) data modification takes place.
    > I generate regular subclasses and custom superclasses (listed bellow)
    > - the only customization is the addition of change monitoring code (so
    > that I can bind the beans to my GUI via jgoodies binding).
    >
    > This is a major problem - I don't know where to start with it... :-(
    >
    > t.n.a.
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > #if( ${classGen.isUsingPackage()} )
    > package ${classGen.packageName};
    >
    > #end
    > #if( ${classGen.isContainingDeclaredListProperties()} )
    > import java.util.List;
    >
    > #end
    > /** Class ${classGen.superPrefix}${classGen.className} was
    > generated by Cayenne.
    > * It is probably a good idea to avoid changing this class manually,
    > * since it may be overwritten next time code is regenerated.
    > * If you need to make any customizations, please use subclass.
    > */
    > public class ${classGen.superPrefix}${classGen.className} extends
    > $classGen.superClassName {
    >
    >
    > // CUSTOM CODE
    > private java.beans.PropertyChangeSupport propertyChangeSupport =
    > new java.beans.PropertyChangeSupport(this);
    >
    > ## Create property names
    > #foreach( $attr in ${classGen.Entity.DeclaredAttributes} )
    > #set( $classGen.Prop = $attr.Name )## let controller know about
    > current property
    > public static final String ${classGen.propAsConstantName}_PROPERTY
    > = "${attr.Name}";
    > #end
    > #foreach( $rel in ${classGen.Entity.DeclaredRelationships} )
    > #set( $classGen.Prop = $rel.Name )## let controller know about
    > current property
    > public static final String ${classGen.propAsConstantName}_PROPERTY
    > = "${rel.Name}";
    > #end
    >
    > #if( $classGen.Entity.DbEntity )
    > #foreach( $idAttr in ${classGen.Entity.DbEntity.PrimaryKey} )
    > #set( $classGen.Prop = $idAttr.Name )## let controller know about
    > current property
    > public static final String
    > ${classGen.propAsConstantName}_PK_COLUMN = "${idAttr.Name}";
    > #end
    > #end
    >
    >
    > // CUSTOM CODE
    > public void addPropertyChangeListener
    > (java.beans.PropertyChangeListener l) {
    > propertyChangeSupport.addPropertyChangeListener(l);
    > }
    >
    > public void
    > removePropertyChangeListener(java.beans.PropertyChangeListener l) {
    > propertyChangeSupport.removePropertyChangeListener(l);
    > }
    >
    > ## Create attribute set/get methods
    > #foreach( $attr in ${classGen.Entity.DeclaredAttributes} )
    > #set( $classGen.Prop = $attr.Name )## let controller know about
    > current property
    > #if ("true" != "${classGen.getEntity().isReadOnly()}")
    > public void
    > set${classGen.cappedProp}($classGen.formatJavaType(${attr.Type})
    > $classGen.formatVariableName(${attr.Name})) {
    > // CUSTOM CODE
    > $classGen.formatJavaType(${attr.Type}) staro_${attr.Name} =
    > ($classGen.formatJavaType(${attr.Type}))readProperty("${attr.Name}");
    >
    > writeProperty("${attr.Name}",
    > $classGen.formatVariableName(${attr.Name}));
    > // CUSTOM CODE
    > propertyChangeSupport.firePropertyChange ("${attr.Name}",
    > staro_${attr.Name}, ${attr.Name});
    > }
    > #end
    > public $classGen.formatJavaType(${attr.Type}) get$
    > {classGen.cappedProp}() {
    > return ($classGen.formatJavaType(${attr.Type}))readProperty
    > ("${attr.Name}");
    > }
    >
    >
    > #end
    > ##
    > ## Create list add/remove/get methods
    > #foreach( $rel in ${classGen.Entity.DeclaredRelationships} )
    > #set( $classGen.Prop = $rel.Name )## let controller know about
    > current property
    > #if( $rel.ToMany )
    > #if ( ! $rel.ReadOnly )
    > public void
    > addTo${classGen.cappedProp}($classGen.formatJavaType($
    > {rel.TargetEntity.ClassName})
    > obj) {
    > addToManyTarget("${rel.name}", obj, true);
    > }
    > public void
    > removeFrom${classGen.cappedProp}($classGen.formatJavaType($
    > {rel.TargetEntity.ClassName})
    > obj) {
    > removeToManyTarget("${rel.name}", obj, true);
    > }
    > #end
    > public List get${classGen.cappedProp}() {
    > return (List)readProperty("${rel.name}");
    > }
    > #else
    > #if ( !${classGen.getEntity().isReadOnly()} && !$rel.ReadOnly )
    > public void
    > set${classGen.cappedProp}($classGen.formatJavaType($
    > {rel.TargetEntity.ClassName})
    > $classGen.formatVariableName(${rel.name})) {
    > // SHOULD ADD CUSTOM CODE, TODO
    > setToOneTarget("${rel.name}",
    > $classGen.formatVariableName(${rel.name}), true);
    > }
    > #end
    >
    > public $classGen.formatJavaType(${rel.TargetEntity.ClassName})
    > get${classGen.cappedProp}() {
    > return ($classGen.formatJavaType($
    > {rel.TargetEntity.ClassName}))readProperty("${rel.name}");
    > }
    > #end
    >
    >
    > #end
    > }



    This archive was generated by hypermail 2.0.0 : Mon Jun 05 2006 - 05:56:31 EDT