Working with JackRabbit OCM

This is a discussion on Working with JackRabbit OCM within the Apache forums in Application Servers & Tools category; Hi guys! I'm new to JackRabbit and now I'm in process of testing JackRabbit OCM feature. I'm stuck with the following issue: I have class Parent: @Node class Parent { @Field private String text; public String getText(){ return this.text; } public void setText(String text){ this.text = text; } } and child class: @Node(extend=Parent.class) class Child { private String y; @Override public String getText(){ return this.y; } @Override public void setText(String text){ this.y = text; } } and doing following: : Child child = new Child(); child.setText("this is child"); // as I understand that code save to "y" attribute ocm.insert(child); ocm.save(); ...

Go Back   Application Development Forum > Application Servers & Tools > Apache

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 11-10-2008, 06:35 AM
Ераскин Алексей
Guest
 
Default Working with JackRabbit OCM

Hi guys!

I'm new to JackRabbit and now I'm in process of testing JackRabbit OCM
feature.

I'm stuck with the following issue:



I have class Parent:



@Node

class Parent {

@Field

private String text;



public String getText(){

return this.text;

}



public void setText(String text){

this.text = text;

}

}



and child class:



@Node(extend=Parent.class)

class Child {



private String y;



@Override

public String getText(){

return this.y;

}



@Override

public void setText(String text){

this.y = text;

}

}



and doing following:



:

Child child = new Child();

child.setText("this is child"); // as I understand that code save to "y"
attribute



ocm.insert(child);

ocm.save();



QueryManager manager = ocm.getQueryManager();

Filter filter = manager.createFilter(AdvTextQuestionData.class);

filter.addLike("text", "%this is child%");



Query query = manager.createQuery(filter);



Collection t1 = ocm.getObjects(query);



:.



In result, collection isn't empty because OCM saves to repository to the
"text" property(annotated field in Parent class) following value: "this is
child" Why?

Actually I don't set this field and for me it's strange behavior: maybe
someone knows something about that?



Tnx a lot, Eraskin Alexey!




Reply With Quote
  #2  
Old 11-10-2008, 07:38 AM
Christophe Lombart
Guest
 
Default Re: Working with JackRabbit OCM

On Mon, Nov 10, 2008 at 12:35, Ераскин Алексей <eraa@1c.ru> wrote:

In result, collection isn't empty because OCM saves to repository to the
> "text" property(annotated field in Parent class) following value: "this is
> child" Why?
>


Because the Child class "extends" the Parent Class (see
@Node(extend=Parent.class) ) in term of OCM mapping and not in term of java.


"@Node(extend=Parent.class)" is a way to get all mapping info from an
ancestor class. this is only used for an inheritance tree which is not your
case I think.

You can solve the problem by replacing "@Node(extend=Parent.class)" by @Node
and add mapping info in the Child class.

FYI, "extend" attribute in @Node is obsolete. I will add a tutorial on the
inheritance support. From now, with the latest build from subversion, it is
possible to write :

@Node
Class MyAncestor
{
// Add fields here
}

@Node
Class MyClass extends MyAncestor
{
// Add fields here
}

MyClass will inherit all mapping info made in the MyAncestor because it is a
descendant of MyAncestor.


Let me know if you need more info

br,
Christophe
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 10:51 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.