Why would you use a relationship instance to populate a friend table?
That seems inappropriate.

At any rate, if you ditch the parameter class (it is not required) it will work.

Larry


On 10/9/06, Guido García Bernardo <[EMAIL PROTECTED]> wrote:

 Imagine the following abstract class:

 public abstract class Relationship {
     private String dateRelation;
     private Integer idUser;
     // getters & setters
 }

 That allows to define several kinds of relations, i.e:

 public class Friendship extends Relationship {
     private String comment;
     // getters & setters
 }

 The SQL map:

     <sqlMap>
         <typeAlias alias="relation" type="my.package.Relationship" />

         <insert id="insertFriend" parameterClass="relation">
             insert into FRIENDS ( id_user, date_relation, comment )
             values ( #idUser#, #dateRelation#, #comment# )
         </insert>
     </sqlMap>

 And my ibatis code throws a message error "There is not readable property
'comment' in my.package.Relationship".

     Relationship friend = new Friendship( ... );
     saveRelation( friend );
     ...

     public void saveRelation(Relationship relation) throws DAOException {
         try {
             if (relation instanceof Friendship) {
                 getSqlMapExecutor().insert( "insertFriend", relation );
             } else if ...
             ...
         } catch (SQLException e) {
             throw new DAOException( "Error saving friend", e );
         }
     }

 Why ibatis does not discover object properties at runtime? Is there any way
to use abstract classes in my sql-map files?
 I am not sure if I have explained my problem properly...

 Thank you very much.
 Guido García Bernardo

Reply via email to