db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "sachinjambagi" <sachinjamb...@indiatimes.com>
Subject problem in m:n relation
Date Tue, 05 Apr 2005 07:18:00 GMT
Hi all,

I am a new bee for OJB.

I got an error in the m:n relationship.

I have two classes 

1)Users - UserName(PK),pwd
2)Role - RoleId(PK),roleName
3)User_role - UserName(FK),RoleId(FK);

The users class contains the collection of the role class object and vice versa.

When I was tring to get a user object by Id the following exception is encountered :-

org.apache.ojb.broker.metadata.MetadataException: IllegalAccess error setting field:users
in object:test.core.Role
        at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessImplNew.setValueFor(PersistentFieldDirectAccessImplNew.java:226)
        at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessImplNew.set(PersistentFieldDirectAccessImplNew.java:158)
        at org.apache.ojb.broker.core.QueryReferenceBroker.retrieveCollection(QueryReferenceBroker.java:584)
        at org.apache.ojb.broker.core.QueryReferenceBroker.retrieveCollections(QueryReferenceBroker.java:748)
        at org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(PersistenceBrokerImpl.java:1303)
        at org.apache.ojb.broker.core.PersistenceBrokerImpl.doGetObjectByIdentity(PersistenceBrokerImpl.java:1367)
        at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(PersistenceBrokerImpl.java:1346)
        at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(PersistenceBrokerImpl.java:1435)
        at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(DelegatingPersistenceBroker.java:307)
        at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(DelegatingPersistenceBroker.java:307)
        at test.db.MySQLStorageEntity.read(MySQLStorageEntity.java:125)
        at test.db.DataManager.read(DataManager.java:151)
        at test.test.User.AssignRole.apply(AssignRole.java:46)
        at test.test.Application.run(Application.[PersistentField] ERROR: while set field:

[try to set 'object value' in 'target object'
target obj class: test.core.Role
target field name: users
target field type: class java.util.Vector
object value class: org.apache.ojb.broker.util.collections.ManageableArrayList
object value: []
]
[PersistentField] ERROR: while set field: 
[try to set 'object value' in 'target object'
target obj class: test.core.User
target field name: roles
target field type: class java.util.Vector
object value class: org.apache.ojb.broker.util.collections.ManageableArrayList
object value: [[1] analyst, [2] programmer]
]
java:101)
        at test.test.Application.main(Application.java:85)
Caused by: java.lang.IllegalArgumentException
        at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
        at java.lang.reflect.Field.set(Field.java:656)
        at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessImplNew.setValueFor(PersistentFieldDirectAccessImplNew.java:213)
        ... 14 more
org.apache.ojb.broker.metadata.MetadataException: IllegalAccess error setting field:roles
in object:test.core.User
        at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessImplNew.setValueFor(PersistentFieldDirectAccessImplNew.java:226)
        at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessImplNew.set(PersistentFieldDirectAccessImplNew.java:158)
        at org.apache.ojb.broker.core.QueryReferenceBroker.retrieveCollection(QueryReferenceBroker.java:584)
        at org.apache.ojb.broker.core.QueryReferenceBroker.retrieveCollections(QueryReferenceBroker.java:748)
        at org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(PersistenceBrokerImpl.java:1303)
        at org.apache.ojb.broker.core.PersistenceBrokerImpl.doGetObjectByIdentity(PersistenceBrokerImpl.java:1367)
        at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(PersistenceBrokerImpl.java:1346)
        at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(PersistenceBrokerImpl.java:1435)
        at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(DelegatingPersistenceBroker.java:307)
        at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(DelegatingPersistenceBroker.java:307)
        at test.db.MySQLStorageEntity.read(MySQLStorageEntity.java:125)
        at test.db.DataManager.read(DataManager.java:151)
        at test.test.User.AssignRole.apply(AssignRole.java:47)
        at test.test.Application.run(Application.java:101)
        at test.test.Application.main(Application.java:85)
Caused by: java.lang.IllegalArgumentException
        at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
        at java.lang.reflect.Field.set(Field.java:656)
        at org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessImplNew.setValueFor(PersistentFieldDirectAccessImplNew.java:213)
        ... 14 more


I will be very thankful If anyone gives me the solution for this problem.


-sachin
Get Your Private, Free E-mail from Indiatimes at http://email.indiatimes.com

 Buy The Best In BOOKS at http://www.bestsellers.indiatimes.com

Bid for for Air Tickets @ Re.1 on Air Sahara Flights. Just log on to http://airsahara.indiatimes.com
and Bid Now!


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message