cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: Modifying projects in Java
Date Sat, 14 Jul 2007 19:13:51 GMT

On Jul 13, 2007, at 1:30 AM, Mikaƫl Cluseau wrote:

> Caused by: java.lang.ClassCastException:  
> org.apache.cayenne.access.DataNode$TransactionDataSource cannot be  
> cast to org.apache.cayenne.project.ProjectDataSource
> 	at org.apache.cayenne.project.DataNodeFile.save(DataNodeFile.java:64)
>
> I don't get how the modeler manages to get it working (it looks pretty
> straightforward so I must be missing something).

To work around a bad decision made a long time ago to use Cayenne  
runtime objects (DataDomain, DataNode) as CayenneModeler model beans,  
modeler often uses inner subclasses to suppress various runtime  
behavior aspects. Here is how i handles the problem above:


class ModelerProjectLoadDelegate extends RuntimeLoadDelegate {
....
  protected DataNode createDataNode(String nodeName) {
         return new DataNode(nodeName) {

             public DataSource getDataSource() {
                 return dataSource;
             }
         };
     }
...
}

Andrus
Mime
View raw message