You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by idan <id...@gmail.com> on 2010/11/01 09:38:18 UTC

StoreManager flush

Hey,

I'm implementing my own StoreManager.
The StoreManager's flush method gets a state managers to flush collection as
parameter.

How can identify relationships (onetoone/onetomany/embedded) within these
state managers.
Is there anything special about how the state managers are ordered in the
collection?

Thanks,
Idan




-- 
View this message in context: http://openjpa.208410.n2.nabble.com/StoreManager-flush-tp5693069p5693069.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.

Re: StoreManager flush

Posted by idan <id...@gmail.com>.
Hey again,

Lets say i have an Owner class which has a OneToMany relation with a Pet
class (owner has a list of Pets).
When updating a Pet instance at flush() .. can i determine to which Owner
instance the Pet is related to?


Thanks,
Idan

-- 
View this message in context: http://openjpa.208410.n2.nabble.com/StoreManager-flush-tp5693069p5743104.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.

Re: StoreManager flush

Posted by Rick Curtis <cu...@gmail.com>.
This is off the top of my head so excuse me if I get something wrong...

> Is there a way to know if an object is a part of a relation by its
ClassMetaData?
Not the ClassMetaData itself. You can look at the fields(FieldMetaData) for
a particualr ClassMetaData.

> For example, if A has a OneToOne relation with B.. can i know that B is in
a relation only by B's ClassMetaData?
If it is a bi-directional relationship, yes. If it is unidirectional I can't
say for certain.

Thanks,
Rick

On Fri, Nov 12, 2010 at 8:47 AM, idan <id...@gmail.com> wrote:

>
> Again.. I did some homework...
>
> loadPersistentTypes is called after the StoreManager.open() method and
> therefore the ClassMetaData array is empty in this stage.
>
> Is there a way to know if an object is a part of a relation by its
> ClassMetaData?
>
> For example, if A has a OneToOne relation with B.. can i know that B is in
> a
> relation only by B's ClassMetaData?
>
> Thanks,
> Idan
>

Re: StoreManager flush

Posted by idan <id...@gmail.com>.
Again.. I did some homework...

loadPersistentTypes is called after the StoreManager.open() method and
therefore the ClassMetaData array is empty in this stage.

Is there a way to know if an object is a part of a relation by its
ClassMetaData?

For example, if A has a OneToOne relation with B.. can i know that B is in a
relation only by B's ClassMetaData?

Thanks,
Idan

-- 
View this message in context: http://openjpa.208410.n2.nabble.com/StoreManager-flush-tp5693069p5732552.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.

Re: StoreManager flush

Posted by idan <id...@gmail.com>.
When trying to get the current ClassMetaData array in StoreManager.open() I'm
getting an empty array.
If i'm trying to get the array in one of the flush() methods I get a filled
array.

Is that normal or perhaps its related to the fact that currently i'm using
subclasses enhancement during development?

Thanks,
Idan


-- 
View this message in context: http://openjpa.208410.n2.nabble.com/StoreManager-flush-tp5693069p5732463.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.

Re: StoreManager flush

Posted by Rick Curtis <cu...@gmail.com>.
Yes

Thanks,
Rick

On Thu, Nov 11, 2010 at 10:47 AM, idan <id...@gmail.com> wrote:

>
> OK
> I found a way to do so through the configuration
> getMetaDataRepositoryInstance()
>
> Is that the right way?
>
>
> Thanks,
> Idan

Re: StoreManager flush

Posted by idan <id...@gmail.com>.
OK
I found a way to do so through the configuration
getMetaDataRepositoryInstance()

Is that the right way?


Thanks,
Idan

-- 
View this message in context: http://openjpa.208410.n2.nabble.com/StoreManager-flush-tp5693069p5729313.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.

Re: StoreManager flush

Posted by idan <id...@gmail.com>.
Hey,

I made some progress and i have a question..
Is it possible to get a hold of the persisted types ClassMetaData's when
initializing my custom StoreManager?
(lets say in its open() method)



Thanks,
Idan

-- 
View this message in context: http://openjpa.208410.n2.nabble.com/StoreManager-flush-tp5693069p5729298.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.

Re: StoreManager flush

Posted by Michael Dick <mi...@gmail.com>.
Glad I could help.

Good luck, and let us know how it goes. Most of the infrastructure for a non
relational store should be in place - I believe Kodo did something similar
(OpenJPA was based on Kodo).

-mike

On Tue, Nov 2, 2010 at 5:51 PM, idan <id...@gmail.com> wrote:

>
> Hey thanks for the help.
>
> I'm implementing my own StoreManager since my data store is not a
> relational
> one
> and has a pojo based API.
>
> My data store does have a JDBC driver but implementing my own StoreManager
> will give me better performance and better handling for relationships.
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/StoreManager-flush-tp5693069p5699462.html
> Sent from the OpenJPA Developers mailing list archive at Nabble.com.
>

Re: StoreManager flush

Posted by idan <id...@gmail.com>.
Hey thanks for the help.

I'm implementing my own StoreManager since my data store is not a relational
one
and has a pojo based API.

My data store does have a JDBC driver but implementing my own StoreManager
will give me better performance and better handling for relationships.

-- 
View this message in context: http://openjpa.208410.n2.nabble.com/StoreManager-flush-tp5693069p5699462.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.

Re: StoreManager flush

Posted by Michael Dick <mi...@gmail.com>.
On Tue, Nov 2, 2010 at 3:51 PM, Rick Curtis <cu...@gmail.com> wrote:

> > I'm implementing my own StoreManager.
> Do you mind me asking why you are implementing your own StoreManager?
>
> > How can identify relationships (onetoone/onetomany/embedded) within these
> state managers.
> You'll want to look at the MetaData(OpenJPAStateManager.getMetaData()) for
> each StateManager.
>
> > Is there anything special about how the state managers are ordered in the
> collection?
> I can't tell you off the top of my head... maybe someone else can help?


By default the state managers are stored in a hash set - so the order when
you iterate over them is non deterministic. You can change this by setting
orderDirty=true on the openjpa.updateManager persistence property (OpenJPA
will use a LinkedMap instead of a HashSet).

Something like this should work :
<property name="openjpa.UpdateManager"
value="operation-order(OrderDirty=true)"/>

This is from memory so I might have the case wrong, or some other dumb typo.
The documentation is a little sparse in this area, if you're interested in
the various values here's the
link.<http://openjpa.apache.org/builds/latest/docs/manual/manual.html#openjpa.jdbc.UpdateManager>

Like Rick I'm curious why you're writing your own StoreManager though, but
maybe this will help you get started.

-mike

Re: StoreManager flush

Posted by Rick Curtis <cu...@gmail.com>.
> I'm implementing my own StoreManager.
Do you mind me asking why you are implementing your own StoreManager?

> How can identify relationships (onetoone/onetomany/embedded) within these
state managers.
You'll want to look at the MetaData(OpenJPAStateManager.getMetaData()) for
each StateManager.

> Is there anything special about how the state managers are ordered in the
collection?
I can't tell you off the top of my head... maybe someone else can help?

Thanks,
RIck