Marcus Young wrote:

Hi,

I have two classes 'Role' and 'Group' that extend 'PermissionHolder". PermissionHolder includes as an attribute a collection of PermissionHolders. I am able to store a Role or a Group with contained permission holders successfully. However, I am having difficulties with retrevial. Exception as follows:

[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] DEBUG: executeQuery: [EMAIL PROTECTED]: SELECT A0.NAME,A0.DESCRIPTION,A0.ID FROM roles A0 WHERE A0.ID = 1584
[org.apache.ojb.broker.accesslayer.RsIterator] DEBUG: RsIterator[org.apache.ojb.broker.accesslayer.RsQueryObject[query: QueryByCriteria from class com.eclipsej.user.RoleTO where [_id = 1584], class descriptor: com.eclipsej.user.RoleTO]] initialized
[org.apache.ojb.broker.accesslayer.RsIterator] DEBUG: hasNext() -> true
java.lang.NullPointerException
at org.apache.ojb.broker.metadata.ClassDescriptor.getPkFields(ClassDescriptor.java:1016)


at org.apache.ojb.broker.core.QueryReferenceBroker.getFKQueryMtoN(QueryReferenceBroker.java:660)

at org.apache.ojb.broker.core.Que[org.apache.ojb.broker.core.PersistenceBrokerImpl] DEBUG: PB.close was called: [EMAIL PROTECTED]
[org.apache.ojb.broker.cache.InternalCache] WARN: Found 1 abandoned objects in local cache, check code to force push to real ObjectCache
ryReferenceBroker.getFKQuery(QueryReferenceBroker.java:608)



In this case role (id=1584) has a single group in its collection.
I have also attached a copy of the repository. I'm sure I'm missing something simple - any help would be appreciated....



<!-- Definitions for com.eclipsej.permissions.PermissionHolder -->
<class-descriptor class="com.eclipsej.permission.PermissionHolder" table="permission_holders"> <extent-class class-ref="com.eclipsej.user.RoleTO" />
<extent-class class-ref="com.eclipsej.user.GroupTO" />
</class-descriptor> <!-- Defnitions for com.eclipsej.user.RoleTO -->
<class-descriptor class="com.eclipsej.user.RoleTO" table="roles">
<field-descriptor name="_id" column="ID" jdbc-type="BIGINT" primarykey="true" autoincrement="true"/>
<field-descriptor name="_name" column="NAME" jdbc-type="VARCHAR"/>
<field-descriptor name="_description" column="DESCRIPTION" jdbc-type="VARCHAR"/> <collection-descriptor name="_permissionHolders"
element-class-ref="com.eclipsej.permission.PermissionHolder"
auto-retreive="true"
auto-update="true"
auto-delete="false"
indirection-table="permission_holder_map"
>
<fk-pointing-to-this-class column="permission_holder_host_id"/>
<fk-pointing-to-element-class column="permission_holder_client_id"/>
</collection-descriptor> </class-descriptor>

Your m:n collection points to PermissionHolder, however this 'class' has no declared primary key field. Try adding the primary key field descriptor to it. Note that the primary key must be unique across RoleTO and GroupTO to make this work. You might also run into problems if you map RoleTO and GroupTO to different tables because in this case OJB currently has no way to determine which class to instantiate (there are plans to add support for a field containing the concrete class name to the referee side, e.g. the indirection table in your case, but they ain't implemented yet).


Tom


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



Reply via email to