You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Björn Voigt <bv...@hs-harz.de> on 2004/06/17 12:49:38 UTC
NullPointerException on getObject (1:n)
NullPointerException I don't know why,
1:n Relation Account has one or more Users.
The storing of Account-Object including
User-Object in users-collection is successful.
But I cannot get it back from db without a
NullPointerException.
I think I've done all right but I cannot find the
problem.
Thank you for your help
Björn
<class-descriptor class="com.itgis.cocoon.model.account.Account"
table="account">
<field-descriptor name="accountid" column="accountid"
jdbc-type="INTEGER" primarykey="true" autoincrement="true" />
[...]
<collection-descriptor name="users"
element-class="com.itgis.cocoon.model.account.User"
orderby="articleid" sort="DESC"
auto-retrieve="true" auto-update="true" auto-delete="true">
<inverse-foreignkey field-ref="accountid"/>
</collection-descriptor>
</class-descriptor>
<class-descriptor class="com.itgis.cocoon.model.account.User" table="users">
<field-descriptor name="userid" column="userid"
jdbc-type="VARCHAR" primarykey="true"/>
<field-descriptor name="accountid" column="accountid"
jdbc-type="INTEGER" access="anonymous"/>
[...]
</class-descriptor>
Exception in thread "main" java.lang.NullPointerException
at
org.apache.ojb.broker.metadata.DescriptorRepository.getDescriptorFor(DescriptorRepository.java:446)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getClassDescriptor(PersistenceBrokerImpl.java:1506)
at
org.apache.ojb.broker.core.QueryReferenceBroker.getFKQuery1toN(QueryReferenceBroker.java:643)
at
org.apache.ojb.broker.core.QueryReferenceBroker.getFKQuery(QueryReferenceBroker.java:577)
at
org.apache.ojb.broker.core.QueryReferenceBroker.retrieveCollection(QueryReferenceBroker.java:508)
at
org.apache.ojb.broker.core.QueryReferenceBroker.retrieveCollections(QueryReferenceBroker.java:695)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(PersistenceBrokerImpl.java:1089)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(PersistenceBrokerImpl.java:1145)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(PersistenceBrokerImpl.java:1212)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(DelegatingPersistenceBroker.java:291)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(DelegatingPersistenceBroker.java:291)
at Test.main(Test.java:34)
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Both sides of M:N mapping not correctly retrieved in rc7
Posted by Bradford Pielech <br...@alphatech.com>.
Armin:
Thanks a lot for the help. It works now. In addition to what you
pointed out, I also had a bug on my side related to interfaces and extents
that caused OJB to get confused when connecting collections.
thanks again,
Brad
I also noticed the problem with the
At 08:32 PM 6/23/2004 +0200, you wrote:
>Hi Brad,
>
>good news! Seems to work.
>
>I checked in a new test case show how to use PB-api to
>store/retrieve/delete object hierarchies via m:n relation with different
>collection-descriptor auto-xxx settings.
>
>Main difference to your test is that I use two table (one for tree object,
>the other as indirection table). But it should also be possible to map
>this stuff in one table (not recommended IMO, because it will mix
>different types of rows).
>
>The test is called "M2NGraphTest.java" (see test-suite, [db-ojb]/src/test)
>and is a little different from yours, but following the example should
>make work your test too.
>
>http://cvs.apache.org/viewcvs.cgi/db-ojb/src/test/org/apache/ojb/broker/M2NGraphTest.java?rev=1.1&view=markup
>
>The metadata mapping can be found in
>src/test/org/apache/ojb repository_junit_reference.xml
>
>By the way, your wrapper methods addEntity, linkEntity use different PB
>instances, thus two connections will be used. If linkEntity fails the
>changes made in addEntity will not be rollback. And you don't close the
>used PB instance.
>But maybe you override this methods in your wrapper too, so my notice is
>wrong ;-)
>
>regards,
>Armin
>
>Bradford Pielech wrote:
>
>>yeah, those are basically wrappers to underlying broker methods.
>>The addEntity method is a wrapper for the following method that accesses
>>the persistence broker:
>>----------------------------
>>public boolean addEntity(SimpleDagNode nodeA) throws Exception {
>> PersistenceBroker pbroker =
>> PersistenceBrokerFactory.defaultPersistenceBroker();
>> pbroker.beginTransaction();
>> pbroker.store(nodeA, modificationType);
>> pbroker.commitTransaction();
>> return true;
>>----------------------------
>>
>>and broker.linkEntity is implemented as follows:
>>----------------------------
>> public void linkEntity(SimpleDagNode parent, SimpleDagNode child)
>> throws Exception {
>> if(!parent.getChildren().contains(child)){
>> parent.addChild(child);
>> }
>> PersistenceBroker pbroker =
>> PersistenceBrokerFactory.defaultPersistenceBroker();
>> pbroker.beginTransaction();
>> pbroker.serviceBrokerHelper().link(o, false);
>> pbroker.commitTransaction();
>>}
>>----------------------------
>>At 03:05 PM 6/23/2004 +0200, you wrote:
>>
>>>seems you use an user specific PersistenceBroker implementation, can you
>>>post methods
>>>
>>>broker.addEntity(nodeA);
>>>broker.linkEntity(nodeA, nodeB);
>>>
>>>too.
>>>
>>>regards,
>>>Armin
>>>
>>>Bradford Pielech wrote:
>>>
>>>>Oops, just realized there was a logic bug in the junit test that makes
>>>>the code incorrect because I had to quickly rewrite the test to remove
>>>>unneeded subclasses and such. Here is the correct version:
>>>>public void testAddNewChild() throws Exception {
>>>> SimpleDAGNode nodeA = new nodeANode();
>>>> SimpleDAGNode nodeB = new nodeBNode();
>>>> //store nodeA first
>>>> broker.addEntity(nodeA);
>>>> //then store the nodeB
>>>> broker.addEntity(nodeB);
>>>> //make A the parent of B because they are not linked in the code
>>>> automatically
>>>> broker.linkEntity(nodeA, nodeB);
>>>> SimpleDAGNode retrievednodeB = broker.getEntity(nodeB.getID());
>>>> assertNotNull("Verifying the nodeB was retrieved", retrievednodeB);
>>>> SimpleDAGNode retrievednodeA = (SimpleDAGNode)
>>>> retrievednodeB.getParentAt(0);
>>>> assertEquals("verify the nodeA was stored", nodeA.getID(),
>>>> retrievednodeA.getEboId());
>>>> assertEquals("verify the retrieved nodeA has 1 child (the nodeB)", 1,
>>>> retrievednodeA.getChildCount());
>>>> assertEquals("verify the retrieved nodeB has 1 parent (the nodeA)", 1,
>>>> retrievednodeB.getParentCount());
>>>> assertEquals(
>>>> "verify, using hashcode, that the nodeB's parent is the nodeA",
>>>> retrievednodeA.hashCode(),
>>>> retrievednodeB.getParentAt(0).hashCode());
>>>> for (Iterator i = retrievednodeA.getChildren().iterator();
>>>> i.hasNext(); ) {
>>>> Object o = i.next();
>>>> //this next test fails because the child is null
>>>> assertNotNull("Verifying nodeA's children are not null", o);
>>>> assertEquals(
>>>> "verify, using hashcode, that the nodeAs child is the nodeB",
>>>> retrievednodeB.hashCode(), o.hashCode());
>>>> }
>>>> }
>>>>
>>>>
>>>>At 08:18 AM 6/23/2004 -0400, you wrote:
>>>>
>>>>>Armin:
>>>>>
>>>>> Sure, no problem. Apologies for the formatting, but the basic
>>>>> idea should be clear. I also attached my OJB.properties and
>>>>> repository_user.xml.
>>>>>
>>>>>thanks!
>>>>>Brad
>>>>>
>>>>>
>>>>>SimpleDagNode class:
>>>>>---------------------------------------
>>>>>public class SimpleDAGNode{
>>>>>
>>>>> private List children;
>>>>> private String ID;
>>>>> private List parents;
>>>>>
>>>>> public SimpleDAGNode() {
>>>>> ID = "";
>>>>> parents = new Vector();
>>>>> children = new Vector();
>>>>> }
>>>>> public String getID() {
>>>>> return ID;
>>>>> }
>>>>> public void addChildNode(DAGNode child) {
>>>>> // Cannot add same child twice
>>>>> if (!children.contains(child)) {
>>>>> children.add(child);
>>>>> if (!child.getParents().contains(this)) {
>>>>> child.getParents().add(this);
>>>>> }
>>>>>
>>>>> }
>>>>>
>>>>> }
>>>>> public void removeChild(DAGNode child) {
>>>>> children.remove(child);
>>>>> child.getParents().remove(this);
>>>>> }
>>>>>
>>>>> public List getParents() {
>>>>> return parents;
>>>>> }
>>>>>
>>>>> public List getChildren() {
>>>>> return children;
>>>>> }
>>>>>
>>>>> public boolean equals(Object ref) {
>>>>> if (ref == null) {
>>>>> return false;
>>>>> }
>>>>> if (ref instanceof SimpleDagNode) {
>>>>> return (getID().equals( ( (SimpleDagNode) ref).getID()));
>>>>> }
>>>>> else {
>>>>> return false;
>>>>> }
>>>>> }
>>>>>}
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Both sides of M:N mapping not correctly retrieved in rc7
Posted by Armin Waibel <ar...@apache.org>.
Hi Brad,
good news! Seems to work.
I checked in a new test case show how to use PB-api to
store/retrieve/delete object hierarchies via m:n relation with different
collection-descriptor auto-xxx settings.
Main difference to your test is that I use two table (one for tree
object, the other as indirection table). But it should also be possible
to map this stuff in one table (not recommended IMO, because it will mix
different types of rows).
The test is called "M2NGraphTest.java" (see test-suite,
[db-ojb]/src/test) and is a little different from yours, but following
the example should make work your test too.
http://cvs.apache.org/viewcvs.cgi/db-ojb/src/test/org/apache/ojb/broker/M2NGraphTest.java?rev=1.1&view=markup
The metadata mapping can be found in
src/test/org/apache/ojb repository_junit_reference.xml
By the way, your wrapper methods addEntity, linkEntity use different PB
instances, thus two connections will be used. If linkEntity fails the
changes made in addEntity will not be rollback. And you don't close the
used PB instance.
But maybe you override this methods in your wrapper too, so my notice is
wrong ;-)
regards,
Armin
Bradford Pielech wrote:
> yeah, those are basically wrappers to underlying broker methods.
>
> The addEntity method is a wrapper for the following method that accesses
> the persistence broker:
> ----------------------------
> public boolean addEntity(SimpleDagNode nodeA) throws Exception {
> PersistenceBroker pbroker =
> PersistenceBrokerFactory.defaultPersistenceBroker();
> pbroker.beginTransaction();
> pbroker.store(nodeA, modificationType);
> pbroker.commitTransaction();
> return true;
> ----------------------------
>
>
>
> and broker.linkEntity is implemented as follows:
> ----------------------------
> public void linkEntity(SimpleDagNode parent, SimpleDagNode child)
> throws Exception {
> if(!parent.getChildren().contains(child)){
> parent.addChild(child);
> }
> PersistenceBroker pbroker =
> PersistenceBrokerFactory.defaultPersistenceBroker();
> pbroker.beginTransaction();
> pbroker.serviceBrokerHelper().link(o, false);
> pbroker.commitTransaction();
> }
> ----------------------------
>
> At 03:05 PM 6/23/2004 +0200, you wrote:
>
>> seems you use an user specific PersistenceBroker implementation, can
>> you post methods
>>
>> broker.addEntity(nodeA);
>> broker.linkEntity(nodeA, nodeB);
>>
>> too.
>>
>> regards,
>> Armin
>>
>> Bradford Pielech wrote:
>>
>>> Oops, just realized there was a logic bug in the junit test that
>>> makes the code incorrect because I had to quickly rewrite the test to
>>> remove unneeded subclasses and such. Here is the correct version:
>>> public void testAddNewChild() throws Exception {
>>> SimpleDAGNode nodeA = new nodeANode();
>>> SimpleDAGNode nodeB = new nodeBNode();
>>> //store nodeA first
>>> broker.addEntity(nodeA);
>>> //then store the nodeB
>>> broker.addEntity(nodeB);
>>> //make A the parent of B because they are not linked in the code
>>> automatically
>>> broker.linkEntity(nodeA, nodeB);
>>> SimpleDAGNode retrievednodeB = broker.getEntity(nodeB.getID());
>>> assertNotNull("Verifying the nodeB was retrieved", retrievednodeB);
>>> SimpleDAGNode retrievednodeA = (SimpleDAGNode)
>>> retrievednodeB.getParentAt(0);
>>> assertEquals("verify the nodeA was stored", nodeA.getID(),
>>> retrievednodeA.getEboId());
>>> assertEquals("verify the retrieved nodeA has 1 child (the
>>> nodeB)", 1,
>>> retrievednodeA.getChildCount());
>>> assertEquals("verify the retrieved nodeB has 1 parent (the
>>> nodeA)", 1,
>>> retrievednodeB.getParentCount());
>>> assertEquals(
>>> "verify, using hashcode, that the nodeB's parent is the nodeA",
>>> retrievednodeA.hashCode(),
>>> retrievednodeB.getParentAt(0).hashCode());
>>> for (Iterator i = retrievednodeA.getChildren().iterator();
>>> i.hasNext(); ) {
>>> Object o = i.next();
>>> //this next test fails because the child is null
>>> assertNotNull("Verifying nodeA's children are not null", o);
>>> assertEquals(
>>> "verify, using hashcode, that the nodeAs child is the nodeB",
>>> retrievednodeB.hashCode(), o.hashCode());
>>> }
>>> }
>>>
>>>
>>> At 08:18 AM 6/23/2004 -0400, you wrote:
>>>
>>>> Armin:
>>>>
>>>> Sure, no problem. Apologies for the formatting, but the
>>>> basic idea should be clear. I also attached my OJB.properties and
>>>> repository_user.xml.
>>>>
>>>> thanks!
>>>> Brad
>>>>
>>>>
>>>> SimpleDagNode class:
>>>> ---------------------------------------
>>>> public class SimpleDAGNode{
>>>>
>>>> private List children;
>>>> private String ID;
>>>> private List parents;
>>>>
>>>> public SimpleDAGNode() {
>>>> ID = "";
>>>> parents = new Vector();
>>>> children = new Vector();
>>>> }
>>>> public String getID() {
>>>> return ID;
>>>> }
>>>> public void addChildNode(DAGNode child) {
>>>> // Cannot add same child twice
>>>> if (!children.contains(child)) {
>>>> children.add(child);
>>>> if (!child.getParents().contains(this)) {
>>>> child.getParents().add(this);
>>>> }
>>>>
>>>> }
>>>>
>>>> }
>>>> public void removeChild(DAGNode child) {
>>>> children.remove(child);
>>>> child.getParents().remove(this);
>>>> }
>>>>
>>>> public List getParents() {
>>>> return parents;
>>>> }
>>>>
>>>> public List getChildren() {
>>>> return children;
>>>> }
>>>>
>>>> public boolean equals(Object ref) {
>>>> if (ref == null) {
>>>> return false;
>>>> }
>>>> if (ref instanceof SimpleDagNode) {
>>>> return (getID().equals( ( (SimpleDagNode) ref).getID()));
>>>> }
>>>> else {
>>>> return false;
>>>> }
>>>> }
>>>> }
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Both sides of M:N mapping not correctly retrieved in rc7
Posted by Bradford Pielech <br...@alphatech.com>.
yeah, those are basically wrappers to underlying broker methods.
The addEntity method is a wrapper for the following method that accesses
the persistence broker:
----------------------------
public boolean addEntity(SimpleDagNode nodeA) throws Exception {
PersistenceBroker pbroker =
PersistenceBrokerFactory.defaultPersistenceBroker();
pbroker.beginTransaction();
pbroker.store(nodeA, modificationType);
pbroker.commitTransaction();
return true;
----------------------------
and broker.linkEntity is implemented as follows:
----------------------------
public void linkEntity(SimpleDagNode parent, SimpleDagNode child) throws
Exception {
if(!parent.getChildren().contains(child)){
parent.addChild(child);
}
PersistenceBroker pbroker =
PersistenceBrokerFactory.defaultPersistenceBroker();
pbroker.beginTransaction();
pbroker.serviceBrokerHelper().link(o, false);
pbroker.commitTransaction();
}
----------------------------
At 03:05 PM 6/23/2004 +0200, you wrote:
>seems you use an user specific PersistenceBroker implementation, can you
>post methods
>
>broker.addEntity(nodeA);
>broker.linkEntity(nodeA, nodeB);
>
>too.
>
>regards,
>Armin
>
>Bradford Pielech wrote:
>>Oops, just realized there was a logic bug in the junit test that makes
>>the code incorrect because I had to quickly rewrite the test to remove
>>unneeded subclasses and such. Here is the correct version:
>>public void testAddNewChild() throws Exception {
>> SimpleDAGNode nodeA = new nodeANode();
>> SimpleDAGNode nodeB = new nodeBNode();
>> //store nodeA first
>> broker.addEntity(nodeA);
>> //then store the nodeB
>> broker.addEntity(nodeB);
>> //make A the parent of B because they are not linked in the code
>> automatically
>> broker.linkEntity(nodeA, nodeB);
>> SimpleDAGNode retrievednodeB = broker.getEntity(nodeB.getID());
>> assertNotNull("Verifying the nodeB was retrieved", retrievednodeB);
>> SimpleDAGNode retrievednodeA = (SimpleDAGNode)
>> retrievednodeB.getParentAt(0);
>> assertEquals("verify the nodeA was stored", nodeA.getID(),
>> retrievednodeA.getEboId());
>> assertEquals("verify the retrieved nodeA has 1 child (the nodeB)", 1,
>> retrievednodeA.getChildCount());
>> assertEquals("verify the retrieved nodeB has 1 parent (the nodeA)", 1,
>> retrievednodeB.getParentCount());
>> assertEquals(
>> "verify, using hashcode, that the nodeB's parent is the nodeA",
>> retrievednodeA.hashCode(),
>> retrievednodeB.getParentAt(0).hashCode());
>> for (Iterator i = retrievednodeA.getChildren().iterator();
>> i.hasNext(); ) {
>> Object o = i.next();
>> //this next test fails because the child is null
>> assertNotNull("Verifying nodeA's children are not null", o);
>> assertEquals(
>> "verify, using hashcode, that the nodeAs child is the nodeB",
>> retrievednodeB.hashCode(), o.hashCode());
>> }
>> }
>>
>>
>>At 08:18 AM 6/23/2004 -0400, you wrote:
>>
>>>Armin:
>>>
>>> Sure, no problem. Apologies for the formatting, but the basic
>>> idea should be clear. I also attached my OJB.properties and
>>> repository_user.xml.
>>>
>>>thanks!
>>>Brad
>>>
>>>
>>>SimpleDagNode class:
>>>---------------------------------------
>>>public class SimpleDAGNode{
>>>
>>> private List children;
>>> private String ID;
>>> private List parents;
>>>
>>> public SimpleDAGNode() {
>>> ID = "";
>>> parents = new Vector();
>>> children = new Vector();
>>> }
>>> public String getID() {
>>> return ID;
>>> }
>>> public void addChildNode(DAGNode child) {
>>> // Cannot add same child twice
>>> if (!children.contains(child)) {
>>> children.add(child);
>>> if (!child.getParents().contains(this)) {
>>> child.getParents().add(this);
>>> }
>>>
>>> }
>>>
>>> }
>>> public void removeChild(DAGNode child) {
>>> children.remove(child);
>>> child.getParents().remove(this);
>>> }
>>>
>>> public List getParents() {
>>> return parents;
>>> }
>>>
>>> public List getChildren() {
>>> return children;
>>> }
>>>
>>> public boolean equals(Object ref) {
>>> if (ref == null) {
>>> return false;
>>> }
>>> if (ref instanceof SimpleDagNode) {
>>> return (getID().equals( ( (SimpleDagNode) ref).getID()));
>>> }
>>> else {
>>> return false;
>>> }
>>> }
>>>}
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Both sides of M:N mapping not correctly retrieved in rc7
Posted by Armin Waibel <ar...@apache.org>.
seems you use an user specific PersistenceBroker implementation, can you
post methods
broker.addEntity(nodeA);
broker.linkEntity(nodeA, nodeB);
too.
regards,
Armin
Bradford Pielech wrote:
> Oops, just realized there was a logic bug in the junit test that makes
> the code incorrect because I had to quickly rewrite the test to remove
> unneeded subclasses and such. Here is the correct version:
>
> public void testAddNewChild() throws Exception {
>
> SimpleDAGNode nodeA = new nodeANode();
> SimpleDAGNode nodeB = new nodeBNode();
> //store nodeA first
> broker.addEntity(nodeA);
> //then store the nodeB
> broker.addEntity(nodeB);
> //make A the parent of B because they are not linked in the code
> automatically
> broker.linkEntity(nodeA, nodeB);
>
> SimpleDAGNode retrievednodeB = broker.getEntity(nodeB.getID());
> assertNotNull("Verifying the nodeB was retrieved", retrievednodeB);
> SimpleDAGNode retrievednodeA = (SimpleDAGNode)
> retrievednodeB.getParentAt(0);
> assertEquals("verify the nodeA was stored", nodeA.getID(),
> retrievednodeA.getEboId());
> assertEquals("verify the retrieved nodeA has 1 child (the nodeB)", 1,
> retrievednodeA.getChildCount());
> assertEquals("verify the retrieved nodeB has 1 parent (the nodeA)", 1,
> retrievednodeB.getParentCount());
> assertEquals(
> "verify, using hashcode, that the nodeB's parent is the nodeA",
> retrievednodeA.hashCode(),
> retrievednodeB.getParentAt(0).hashCode());
> for (Iterator i = retrievednodeA.getChildren().iterator();
> i.hasNext(); ) {
> Object o = i.next();
> //this next test fails because the child is null
> assertNotNull("Verifying nodeA's children are not null", o);
> assertEquals(
> "verify, using hashcode, that the nodeAs child is the nodeB",
> retrievednodeB.hashCode(), o.hashCode());
> }
> }
>
>
>
>
> At 08:18 AM 6/23/2004 -0400, you wrote:
>
>> Armin:
>>
>> Sure, no problem. Apologies for the formatting, but the basic
>> idea should be clear. I also attached my OJB.properties and
>> repository_user.xml.
>>
>> thanks!
>> Brad
>>
>>
>> SimpleDagNode class:
>> ---------------------------------------
>> public class SimpleDAGNode{
>>
>> private List children;
>> private String ID;
>> private List parents;
>>
>> public SimpleDAGNode() {
>> ID = "";
>> parents = new Vector();
>> children = new Vector();
>> }
>> public String getID() {
>> return ID;
>> }
>> public void addChildNode(DAGNode child) {
>> // Cannot add same child twice
>> if (!children.contains(child)) {
>> children.add(child);
>> if (!child.getParents().contains(this)) {
>> child.getParents().add(this);
>> }
>>
>> }
>>
>> }
>> public void removeChild(DAGNode child) {
>> children.remove(child);
>> child.getParents().remove(this);
>> }
>>
>> public List getParents() {
>> return parents;
>> }
>>
>> public List getChildren() {
>> return children;
>> }
>>
>> public boolean equals(Object ref) {
>> if (ref == null) {
>> return false;
>> }
>> if (ref instanceof SimpleDagNode) {
>> return (getID().equals( ( (SimpleDagNode) ref).getID()));
>> }
>> else {
>> return false;
>> }
>> }
>> }
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Both sides of M:N mapping not correctly retrieved in rc7
Posted by Bradford Pielech <br...@alphatech.com>.
Oops, just realized there was a logic bug in the junit test that makes the
code incorrect because I had to quickly rewrite the test to remove unneeded
subclasses and such. Here is the correct version:
public void testAddNewChild() throws Exception {
SimpleDAGNode nodeA = new nodeANode();
SimpleDAGNode nodeB = new nodeBNode();
//store nodeA first
broker.addEntity(nodeA);
//then store the nodeB
broker.addEntity(nodeB);
//make A the parent of B because they are not linked in the code
automatically
broker.linkEntity(nodeA, nodeB);
SimpleDAGNode retrievednodeB = broker.getEntity(nodeB.getID());
assertNotNull("Verifying the nodeB was retrieved", retrievednodeB);
SimpleDAGNode retrievednodeA = (SimpleDAGNode)
retrievednodeB.getParentAt(0);
assertEquals("verify the nodeA was stored", nodeA.getID(),
retrievednodeA.getEboId());
assertEquals("verify the retrieved nodeA has 1 child (the nodeB)", 1,
retrievednodeA.getChildCount());
assertEquals("verify the retrieved nodeB has 1 parent (the nodeA)", 1,
retrievednodeB.getParentCount());
assertEquals(
"verify, using hashcode, that the nodeB's parent is the nodeA",
retrievednodeA.hashCode(),
retrievednodeB.getParentAt(0).hashCode());
for (Iterator i = retrievednodeA.getChildren().iterator();
i.hasNext(); ) {
Object o = i.next();
//this next test fails because the child is null
assertNotNull("Verifying nodeA's children are not null", o);
assertEquals(
"verify, using hashcode, that the nodeAs child is the nodeB",
retrievednodeB.hashCode(), o.hashCode());
}
}
At 08:18 AM 6/23/2004 -0400, you wrote:
>Armin:
>
> Sure, no problem. Apologies for the formatting, but the basic
> idea should be clear. I also attached my OJB.properties and
> repository_user.xml.
>
>thanks!
>Brad
>
>
>SimpleDagNode class:
>---------------------------------------
>public class SimpleDAGNode{
>
> private List children;
> private String ID;
> private List parents;
>
> public SimpleDAGNode() {
> ID = "";
> parents = new Vector();
> children = new Vector();
> }
> public String getID() {
> return ID;
> }
> public void addChildNode(DAGNode child) {
> // Cannot add same child twice
> if (!children.contains(child)) {
> children.add(child);
> if (!child.getParents().contains(this)) {
> child.getParents().add(this);
> }
>
> }
>
> }
> public void removeChild(DAGNode child) {
> children.remove(child);
> child.getParents().remove(this);
> }
>
> public List getParents() {
> return parents;
> }
>
> public List getChildren() {
> return children;
> }
>
> public boolean equals(Object ref) {
> if (ref == null) {
> return false;
> }
> if (ref instanceof SimpleDagNode) {
> return (getID().equals( ( (SimpleDagNode) ref).getID()));
> }
> else {
> return false;
> }
> }
>}
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Both sides of M:N mapping not correctly retrieved in rc7
Posted by Bradford Pielech <br...@alphatech.com>.
Armin:
Sure, no problem. Apologies for the formatting, but the basic idea should
be clear. I also attached my OJB.properties and repository_user.xml.
thanks!
Brad
SimpleDagNode class:
---------------------------------------
public class SimpleDAGNode{
private List children;
private String ID;
private List parents;
public SimpleDAGNode() {
ID = "";
parents = new Vector();
children = new Vector();
}
public String getID() {
return ID;
}
public void addChildNode(DAGNode child) {
// Cannot add same child twice
if (!children.contains(child)) {
children.add(child);
if (!child.getParents().contains(this)) {
child.getParents().add(this);
}
}
}
public void removeChild(DAGNode child) {
children.remove(child);
child.getParents().remove(this);
}
public List getParents() {
return parents;
}
public List getChildren() {
return children;
}
public boolean equals(Object ref) {
if (ref == null) {
return false;
}
if (ref instanceof SimpleDagNode) {
return (getID().equals( ( (SimpleDagNode) ref).getID()));
}
else {
return false;
}
}
}
-------------------------------------------------------
Junit Test:
public void testAddNewChild() throws Exception {
logger.info("Testing persisting a relationship");
SimpleDagNode nodeA = new SimpleDagNode();
SimpleDagNode nodeB = new SimpleDagNode();
//store nodeA first
broker.addEntity(nodeA);
//then store the nodeB
broker.addEntity(nodeB );
broker.linkEntity(nodeA, nodeB);
SimpleDagNode retrievedA = broker.retrieve(nodeA.getID());
SimpleDagNode retrievedB = (SimpleDagNode) retrievedA.getParents().get(0);
assertEquals("verify the nodeA was stored", nodeA.getD(),
retrievedA .getID());
assertEquals("verify the retrieved A has 1 child", 1,
retrievedA.getChildren().size());
assertEquals("verify the retrieved B has 1 parent", 1,
retrievedB .getParents().get(0));
assertEquals(
"verify, using hashcode, that the B's parent is A",
retrievedA.hashCode(),
retrievedB.getParents().get(0).hashCode());
for (Iterator i = retrievedA.getChildren().iterator(); i.hasNext(); ) {
Object o = i.next();
/**
* This next line fails. Even though A has 1 child (verified
above), its child is null
*/
assertNotNull("Verifying A's children are not null",
o);
assertEquals(
"verify, using hashcode, that the A's child is B",
retrievedB.hashCode(), o.hashCode());
}
}
Re: Both sides of M:N mapping not correctly retrieved in rc7
Posted by Armin Waibel <ar...@apache.org>.
Hi Brad,
could you please send a junit test or a code snip to reproduce this
behavior? I will integrate your test to test-suite.
regards,
Armin
Bradford Pielech wrote:
> Hello again:
>
> I have encountered an issue with the recursive graph structure that
> I asked about a couple of weeks ago. Below is a snippet from the
> repository.xml. Basically I have a DAGNode that has a list of parents
> and a list of children. I am able to get everything loaded in OJB
> correctly, however I have a problem when I retrieve the objects. Say, I
> have a DAGNode A and B where A is the parent and B is the child. I then
> store A and B in the DB. When I retrieve A, A's child list correctly
> has B, but B's parent list contains 1 object that is null. So if I call
> B.getParents().size(), it returns 1, but the only value in there is a
> null. Conversely, if I retrieve B, B's parent list is correct, but A's
> child list has 1 entry that is a null.
>
> Any ideas what is going on?
>
> thanks!
> Brad
>
> repository_user.xml
> ----------------------------
> <class-descriptor
> class="SimpleDAGNode"
> table="effect"
> >
> <field-descriptor
> name="ID"
> column="ebo_id"
> jdbc-type="VARCHAR"
> primarykey="true"
> length="35"
> >
> </field-descriptor>
> <collection-descriptor
> name="children"
>
> collection-class="org.apache.ojb.broker.util.collections.ManageableArrayList"
>
> element-class-ref="SimpleDAGNode"
> indirection-table="parent_children_table"
> auto-retrieve="true"
> auto-update="none"
> auto-delete="none"
> >
> <fk-pointing-to-this-class column="parent_id"/>
> <fk-pointing-to-element-class column="child_id"/>
> </collection-descriptor>
>
> <collection-descriptor
> name="parents"
> element-class-ref="SimpleDAGNode"
>
> collection-class="org.apache.ojb.broker.util.collections.ManageableArrayList"
>
> indirection-table="parent_children_table"
> auto-retrieve="true"
> auto-update="none"
> auto-delete="none"
> >
> <fk-pointing-to-this-class column="child_id"/>
> <fk-pointing-to-element-class column="parent_id"/>
> </collection-descriptor>
> </class-descriptor>
> --------------------
>
> Relevant other settings:
>
> PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessImpl
>
> ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCachePerBrokerImpl
>
> using rc7 downloaded from website
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Both sides of M:N mapping not correctly retrieved in rc7
Posted by Bradford Pielech <br...@alphatech.com>.
Hello again:
I have encountered an issue with the recursive graph structure that I
asked about a couple of weeks ago. Below is a snippet from the
repository.xml. Basically I have a DAGNode that has a list of parents and
a list of children. I am able to get everything loaded in OJB correctly,
however I have a problem when I retrieve the objects. Say, I have a
DAGNode A and B where A is the parent and B is the child. I then store A
and B in the DB. When I retrieve A, A's child list correctly has B, but
B's parent list contains 1 object that is null. So if I call
B.getParents().size(), it returns 1, but the only value in there is a
null. Conversely, if I retrieve B, B's parent list is correct, but A's
child list has 1 entry that is a null.
Any ideas what is going on?
thanks!
Brad
repository_user.xml
----------------------------
<class-descriptor
class="SimpleDAGNode"
table="effect"
>
<field-descriptor
name="ID"
column="ebo_id"
jdbc-type="VARCHAR"
primarykey="true"
length="35"
>
</field-descriptor>
<collection-descriptor
name="children"
collection-class="org.apache.ojb.broker.util.collections.ManageableArrayList"
element-class-ref="SimpleDAGNode"
indirection-table="parent_children_table"
auto-retrieve="true"
auto-update="none"
auto-delete="none"
>
<fk-pointing-to-this-class column="parent_id"/>
<fk-pointing-to-element-class column="child_id"/>
</collection-descriptor>
<collection-descriptor
name="parents"
element-class-ref="SimpleDAGNode"
collection-class="org.apache.ojb.broker.util.collections.ManageableArrayList"
indirection-table="parent_children_table"
auto-retrieve="true"
auto-update="none"
auto-delete="none"
>
<fk-pointing-to-this-class column="child_id"/>
<fk-pointing-to-element-class column="parent_id"/>
</collection-descriptor>
</class-descriptor>
--------------------
Relevant other settings:
PersistentFieldClass=org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectAccessImpl
ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCachePerBrokerImpl
using rc7 downloaded from website
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: NullPointerException on getObject (1:n)
Posted by Armin Waibel <ar...@apache.org>.
Hi Björn,
I assume this call cause the NPE
>
org.apache.ojb.broker.core.QueryReferenceBroker.getFKQuery1toN(QueryReferenceBroker.java:604)
The source looks like
private QueryByCriteria getFKQuery1toN(Object obj, ClassDescriptor cld,
CollectionDescriptor cod)
{
ValueContainer[] container =
pb.serviceBrokerHelper().getKeyValues(cld, obj);
ClassDescriptor refCld = pb.getClassDescriptor(cod.getItemClass());
// line 604
I think the CollectionDescriptor returns 'null' as item class.
So I think something in your mapping or manipulation of metadata (made
by you?) is wrong.
regards,
Armin
Björn Voigt wrote:
> I switched back to rc6 und removed the anonymous attribute,
> but I still get theNullPointerException.
>
>
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> **** startDoc ****
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> > jdbc-connection-descriptor
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> jcd-alias: default
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> default-connection: true
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> platform: PostgreSQL
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> jdbc-level: 3.0
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> driver: org.postgresql.Driver
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> protocol: jdbc
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> subprotocol: postgresql
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> dbalias: portal?autoReconnect=true
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> jndi-datasource-name: null
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> username: portal
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> password:
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> eager-release: false
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> batch-mode: false
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> useAutoCommit: 1
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> ignoreAutoCommitExceptions: false
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> > connection-pool
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> maxActive: 21
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> maxIdle: null
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> maxWait: null
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> minEvictableIdleTimeMillis: null
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> numTestsPerEvictionRun: null
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> testOnBorrow: null
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> testOnReturn: null
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> testWhileIdle: null
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> timeBetweenEvictionRunsMillis: null
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> whenExhaustedAction: null
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> connectionFactory: null
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> validationQuery:
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> logAbandoned: null
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> removeAbandoned: null
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> removeAbandonedTimeout: null
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> < connection-pool
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> > sequence-manager
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> className:
> org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> > attribute
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> attribute-name: grabSize attribute-value: 20
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> < attribute
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> > attribute
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> attribute-name: autoNaming attribute-value: true
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> < attribute
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> > attribute
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> attribute-name: globalSequenceId attribute-value: false
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> < attribute
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> > attribute
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> attribute-name: globalSequenceStart attribute-value: 10000
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> < attribute
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> < sequence-manager
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> < jdbc-connection-descriptor
> [org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> **** endDoc ****
> [org.apache.ojb.broker.metadata.ConnectionRepository] DEBUG: New
> descriptor was added:
> org.apache.ojb.broker.metadata.JdbcConnectionDescriptor@132e13d[
> jcd-alias=default
> default-connection=true
> dbms=PostgreSQL
> jdbc-level=3.0
> driver=org.postgresql.Driver
> protocol=jdbc
> sub-protocol=postgresql
> db-alias=portal?autoReconnect=true
> user=portal
> password=*****
> eager-release=false
> ConnectionPoolDescriptor={whenExhaustedAction=0, maxIdle=-1,
> maxActive=21, maxWait=5000, removeAbandoned=false,
> numTestsPerEvictionRun=10, testWhileIdle=false,
> minEvictableIdleTimeMillis=600000, testOnReturn=false,
> logAbandoned=false, removeAbandonedTimeout=300,
> timeBetweenEvictionRunsMillis=-1, testOnBorrow=true}
> batchMode=false
> useAutoCommit=AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE
> ignoreAutoCommitExceptions=false
>
> sequenceDescriptor=org.apache.ojb.broker.metadata.SequenceDescriptor@872380[
>
> sequenceManagerClass=class
> org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl
> Properties={autoNaming=true, globalSequenceId=false,
> globalSequenceStart=10000, grabSize=20}
> ]
> ]
> [org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl] INFO:
> Create new PB instance for PBKey org.apache.ojb.broker.PBKey:
> jcdAlias=default, user=portal, password=*****, already created
> persistence broker instances: 0
> [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Start creating
> new ObjectCache instance
> [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Default
> ObjectCache class was org.apache.ojb.broker.cache.ObjectCacheDefaultImpl
> [org.apache.ojb.broker.cache.CacheDistributor] INFO: Use property
> 'descriptorBasedCaches' is set 'false'
> [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Instantiate new
> org.apache.ojb.broker.cache.CacheDistributor class object
> [org.apache.ojb.broker.cache.ObjectCacheFactory] DEBUG: Object cache
> created, using
> cache:org.apache.ojb.broker.cache.CacheDistributor@ba9340[Associated
> PB=org.apache.ojb.broker.core.PersistenceBrokerImpl@1198891,Used default
> cache=org.apache.ojb.broker.cache.ObjectCacheDefaultImpl@1551d7f[Count
> of cached objects=0,Lookup hits=0,Failures=0,Reclaimed=0],Mapped caches={}]
> [org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: New ObjectCache
> instance was created
> [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG:
> Default sequence manager class was
> org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl
> [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG:
> create new sequence manager for broker
> org.apache.ojb.broker.core.PersistenceBrokerImpl@1198891
> [org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG:
> Jdbc-Connection-Descriptor 'default' use sequence manager: class
> org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl
> [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] INFO:
> Create new connection
> pool:org.apache.ojb.broker.metadata.JdbcConnectionDescriptor@132e13d[
> jcd-alias=default
> default-connection=true
> dbms=PostgreSQL
> jdbc-level=3.0
> driver=org.postgresql.Driver
> protocol=jdbc
> sub-protocol=postgresql
> db-alias=portal?autoReconnect=true
> user=portal
> password=*****
> eager-release=false
> ConnectionPoolDescriptor={whenExhaustedAction=0, maxIdle=-1,
> maxActive=21, maxWait=5000, removeAbandoned=false,
> numTestsPerEvictionRun=10, testWhileIdle=false,
> minEvictableIdleTimeMillis=600000, testOnReturn=false,
> logAbandoned=false, removeAbandonedTimeout=300,
> timeBetweenEvictionRunsMillis=-1, testOnBorrow=true}
> batchMode=false
> useAutoCommit=AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE
> ignoreAutoCommitExceptions=false
>
> sequenceDescriptor=org.apache.ojb.broker.metadata.SequenceDescriptor@872380[
>
> sequenceManagerClass=class
> org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl
> Properties={autoNaming=true, globalSequenceId=false,
> globalSequenceStart=10000, grabSize=20}
> ]
> ]
> [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG:
> createPool was called
> [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG:
> makeObject called
> [org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] DEBUG: Request
> new connection from ConnectionFactory:
> org.postgresql.jdbc3.Jdbc3Connection@6cb8
> [org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] DEBUG:
> localBegin was called for con org.postgresql.jdbc3.Jdbc3Connection@6cb8
> [org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] DEBUG: Try to
> change autoCommit state to 'false'
> [org.apache.ojb.broker.accesslayer.StatementManager] DEBUG:
> closeResources was called
> Exception in thread "main" java.lang.NullPointerException
> at
> org.apache.ojb.broker.metadata.DescriptorRepository.getDescriptorFor(DescriptorRepository.java:407)
>
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getClassDescriptor(PersistenceBrokerImpl.java:1680)
>
> at
> org.apache.ojb.broker.core.QueryReferenceBroker.getFKQuery1toN(QueryReferenceBroker.java:604)
>
> at
> org.apache.ojb.broker.core.QueryReferenceBroker.getFKQuery(QueryReferenceBroker.java:538)
>
> at
> org.apache.ojb.broker.core.QueryReferenceBroker.retrieveCollection(QueryReferenceBroker.java:469)
>
> at
> org.apache.ojb.broker.core.QueryReferenceBroker.retrieveCollections(QueryReferenceBroker.java:656)
>
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(PersistenceBrokerImpl.java:1291)
>
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.doGetObjectByIdentity(PersistenceBrokerImpl.java:1355)
>
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(PersistenceBrokerImpl.java:1334)
>
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(PersistenceBrokerImpl.java:1422)
>
> at
> org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(DelegatingPersistenceBroker.java:300)
>
> at
> org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(DelegatingPersistenceBroker.java:300)
>
> at Test.main(Test.java:33)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: NullPointerException on getObject (1:n)
Posted by Björn Voigt <bv...@hs-harz.de>.
I switched back to rc6 und removed the anonymous attribute,
but I still get theNullPointerException.
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
**** startDoc ****
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> jdbc-connection-descriptor
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
jcd-alias: default
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
default-connection: true
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
platform: PostgreSQL
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
jdbc-level: 3.0
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
driver: org.postgresql.Driver
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
protocol: jdbc
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
subprotocol: postgresql
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
dbalias: portal?autoReconnect=true
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
jndi-datasource-name: null
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
username: portal
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
password:
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
eager-release: false
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
batch-mode: false
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
useAutoCommit: 1
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
ignoreAutoCommitExceptions: false
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> connection-pool
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
maxActive: 21
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
maxIdle: null
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
maxWait: null
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
minEvictableIdleTimeMillis: null
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
numTestsPerEvictionRun: null
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
testOnBorrow: null
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
testOnReturn: null
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
testWhileIdle: null
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
timeBetweenEvictionRunsMillis: null
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
whenExhaustedAction: null
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
connectionFactory: null
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
validationQuery:
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
logAbandoned: null
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
removeAbandoned: null
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
removeAbandonedTimeout: null
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
< connection-pool
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> sequence-manager
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
className:
org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> attribute
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
attribute-name: grabSize attribute-value: 20
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
< attribute
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> attribute
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
attribute-name: autoNaming attribute-value: true
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
< attribute
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> attribute
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
attribute-name: globalSequenceId attribute-value: false
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
< attribute
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
> attribute
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
attribute-name: globalSequenceStart attribute-value: 10000
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
< attribute
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
< sequence-manager
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
< jdbc-connection-descriptor
[org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler] DEBUG:
**** endDoc ****
[org.apache.ojb.broker.metadata.ConnectionRepository] DEBUG: New
descriptor was added:
org.apache.ojb.broker.metadata.JdbcConnectionDescriptor@132e13d[
jcd-alias=default
default-connection=true
dbms=PostgreSQL
jdbc-level=3.0
driver=org.postgresql.Driver
protocol=jdbc
sub-protocol=postgresql
db-alias=portal?autoReconnect=true
user=portal
password=*****
eager-release=false
ConnectionPoolDescriptor={whenExhaustedAction=0, maxIdle=-1,
maxActive=21, maxWait=5000, removeAbandoned=false,
numTestsPerEvictionRun=10, testWhileIdle=false,
minEvictableIdleTimeMillis=600000, testOnReturn=false,
logAbandoned=false, removeAbandonedTimeout=300,
timeBetweenEvictionRunsMillis=-1, testOnBorrow=true}
batchMode=false
useAutoCommit=AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE
ignoreAutoCommitExceptions=false
sequenceDescriptor=org.apache.ojb.broker.metadata.SequenceDescriptor@872380[
sequenceManagerClass=class
org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl
Properties={autoNaming=true, globalSequenceId=false,
globalSequenceStart=10000, grabSize=20}
]
]
[org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl] INFO:
Create new PB instance for PBKey org.apache.ojb.broker.PBKey:
jcdAlias=default, user=portal, password=*****, already created
persistence broker instances: 0
[org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Start creating
new ObjectCache instance
[org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Default
ObjectCache class was org.apache.ojb.broker.cache.ObjectCacheDefaultImpl
[org.apache.ojb.broker.cache.CacheDistributor] INFO: Use property
'descriptorBasedCaches' is set 'false'
[org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: Instantiate new
org.apache.ojb.broker.cache.CacheDistributor class object
[org.apache.ojb.broker.cache.ObjectCacheFactory] DEBUG: Object cache
created, using
cache:org.apache.ojb.broker.cache.CacheDistributor@ba9340[Associated
PB=org.apache.ojb.broker.core.PersistenceBrokerImpl@1198891,Used default
cache=org.apache.ojb.broker.cache.ObjectCacheDefaultImpl@1551d7f[Count
of cached objects=0,Lookup hits=0,Failures=0,Reclaimed=0],Mapped caches={}]
[org.apache.ojb.broker.cache.ObjectCacheFactory] INFO: New ObjectCache
instance was created
[org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG:
Default sequence manager class was
org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl
[org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG:
create new sequence manager for broker
org.apache.ojb.broker.core.PersistenceBrokerImpl@1198891
[org.apache.ojb.broker.util.sequence.SequenceManagerFactory] DEBUG:
Jdbc-Connection-Descriptor 'default' use sequence manager: class
org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl
[org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] INFO:
Create new connection
pool:org.apache.ojb.broker.metadata.JdbcConnectionDescriptor@132e13d[
jcd-alias=default
default-connection=true
dbms=PostgreSQL
jdbc-level=3.0
driver=org.postgresql.Driver
protocol=jdbc
sub-protocol=postgresql
db-alias=portal?autoReconnect=true
user=portal
password=*****
eager-release=false
ConnectionPoolDescriptor={whenExhaustedAction=0, maxIdle=-1,
maxActive=21, maxWait=5000, removeAbandoned=false,
numTestsPerEvictionRun=10, testWhileIdle=false,
minEvictableIdleTimeMillis=600000, testOnReturn=false,
logAbandoned=false, removeAbandonedTimeout=300,
timeBetweenEvictionRunsMillis=-1, testOnBorrow=true}
batchMode=false
useAutoCommit=AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE
ignoreAutoCommitExceptions=false
sequenceDescriptor=org.apache.ojb.broker.metadata.SequenceDescriptor@872380[
sequenceManagerClass=class
org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl
Properties={autoNaming=true, globalSequenceId=false,
globalSequenceStart=10000, grabSize=20}
]
]
[org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG:
createPool was called
[org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] DEBUG:
makeObject called
[org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] DEBUG: Request
new connection from ConnectionFactory:
org.postgresql.jdbc3.Jdbc3Connection@6cb8
[org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] DEBUG:
localBegin was called for con org.postgresql.jdbc3.Jdbc3Connection@6cb8
[org.apache.ojb.broker.accesslayer.ConnectionManagerImpl] DEBUG: Try to
change autoCommit state to 'false'
[org.apache.ojb.broker.accesslayer.StatementManager] DEBUG:
closeResources was called
Exception in thread "main" java.lang.NullPointerException
at
org.apache.ojb.broker.metadata.DescriptorRepository.getDescriptorFor(DescriptorRepository.java:407)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getClassDescriptor(PersistenceBrokerImpl.java:1680)
at
org.apache.ojb.broker.core.QueryReferenceBroker.getFKQuery1toN(QueryReferenceBroker.java:604)
at
org.apache.ojb.broker.core.QueryReferenceBroker.getFKQuery(QueryReferenceBroker.java:538)
at
org.apache.ojb.broker.core.QueryReferenceBroker.retrieveCollection(QueryReferenceBroker.java:469)
at
org.apache.ojb.broker.core.QueryReferenceBroker.retrieveCollections(QueryReferenceBroker.java:656)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(PersistenceBrokerImpl.java:1291)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.doGetObjectByIdentity(PersistenceBrokerImpl.java:1355)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(PersistenceBrokerImpl.java:1334)
at
org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(PersistenceBrokerImpl.java:1422)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(DelegatingPersistenceBroker.java:300)
at
org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(DelegatingPersistenceBroker.java:300)
at Test.main(Test.java:33)
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: NullPointerException on getObject (1:n)
Posted by Björn Voigt <bv...@hs-harz.de>.
Armin Waibel wrote:
> Björn Voigt wrote:
>
>> Sorry Armin, but it was the complete stacktrace output.
>> I am running rc7 but i had the same problem with 6 before
>
>
> hmm, strange!
> at
> org.apache.ojb.broker.metadata.DescriptorRepository.getDescriptorFor(DescriptorRepository.java:446)
>
>
> If I go to line 446 in DescriptorRepository it doesn't match
> #getDescriptorFor method. Sure that the stack trace belongs to rc7?
>
> regards
> Armin
>
>>
>> Björn
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
I will check this, i could be, that I havent removed the old
version from my workspace
Björn
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: NullPointerException on getObject (1:n)
Posted by Armin Waibel <ar...@apache.org>.
Björn Voigt wrote:
> Sorry Armin, but it was the complete stacktrace output.
> I am running rc7 but i had the same problem with 6 before
hmm, strange!
at
org.apache.ojb.broker.metadata.DescriptorRepository.getDescriptorFor(DescriptorRepository.java:446)
If I go to line 446 in DescriptorRepository it doesn't match
#getDescriptorFor method. Sure that the stack trace belongs to rc7?
regards
Armin
>
> Björn
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: NullPointerException on getObject (1:n)
Posted by Björn Voigt <bv...@hs-harz.de>.
Sorry Armin, but it was the complete stacktrace output.
I am running rc7 but i had the same problem with 6 before
Björn
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: NullPointerException on getObject (1:n)
Posted by Armin Waibel <ar...@apache.org>.
Hi Björn,
can you post the whole stack trace? Any other error logging output?
Which version do you use?
Maybe it's the same problem with anonymous key posted in thread 'Broker
Helper -> representsNull'
regards,
Armin
Björn Voigt wrote:
> NullPointerException I don't know why,
>
> 1:n Relation Account has one or more Users.
> The storing of Account-Object including
> User-Object in users-collection is successful.
> But I cannot get it back from db without a
> NullPointerException.
>
> I think I've done all right but I cannot find the
> problem.
>
>
> Thank you for your help
>
> Björn
>
>
> <class-descriptor class="com.itgis.cocoon.model.account.Account"
> table="account">
> <field-descriptor name="accountid" column="accountid"
> jdbc-type="INTEGER" primarykey="true" autoincrement="true" />
> [...]
> <collection-descriptor name="users"
> element-class="com.itgis.cocoon.model.account.User"
> orderby="articleid" sort="DESC"
> auto-retrieve="true" auto-update="true" auto-delete="true">
> <inverse-foreignkey field-ref="accountid"/>
> </collection-descriptor>
> </class-descriptor>
>
> <class-descriptor class="com.itgis.cocoon.model.account.User"
> table="users">
> <field-descriptor name="userid" column="userid"
> jdbc-type="VARCHAR" primarykey="true"/>
> <field-descriptor name="accountid" column="accountid"
> jdbc-type="INTEGER" access="anonymous"/>
> [...]
> </class-descriptor>
>
> Exception in thread "main" java.lang.NullPointerException
> at
> org.apache.ojb.broker.metadata.DescriptorRepository.getDescriptorFor(DescriptorRepository.java:446)
>
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getClassDescriptor(PersistenceBrokerImpl.java:1506)
>
> at
> org.apache.ojb.broker.core.QueryReferenceBroker.getFKQuery1toN(QueryReferenceBroker.java:643)
>
> at
> org.apache.ojb.broker.core.QueryReferenceBroker.getFKQuery(QueryReferenceBroker.java:577)
>
> at
> org.apache.ojb.broker.core.QueryReferenceBroker.retrieveCollection(QueryReferenceBroker.java:508)
>
> at
> org.apache.ojb.broker.core.QueryReferenceBroker.retrieveCollections(QueryReferenceBroker.java:695)
>
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(PersistenceBrokerImpl.java:1089)
>
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(PersistenceBrokerImpl.java:1145)
>
> at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(PersistenceBrokerImpl.java:1212)
>
> at
> org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(DelegatingPersistenceBroker.java:291)
>
> at
> org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(DelegatingPersistenceBroker.java:291)
>
> at Test.main(Test.java:34)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org