You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by ralph <ra...@gmail.com> on 2018/03/08 17:36:13 UTC

QueryEntity and inheritence

Hi,

I have some objects that I want to put in an ignite cache and also want to
query them using jdbc sql.
I have used QueryEntity to define the mapping between object model and
relational model.

My problem is :

My objects uses inheritence.
"Asset" object is the parent, and "OTC" object and "Security" Object inherit
from Asset.

Asset
 |-OTC
 |-Security

I would like to have an sql model that is represented with 3 tables
ASSET table which will contain all attributs from Asset Object
OTC table which will contain all specialized attributs from OTC Object
SECURITY table which will contain all specialized attributs from Security
object

And of course all data from 3 tables have to be mapped on the same cache (I
do not want to duplicate data in 2 caches)

Here is what I have done:

assetQueryEntity, OTCQueryEntity, SecurityQueryEntity are QueryEntity
definition for each of the 3 tables :

LinkedList<QueryEntity> qeList = new LinkedList<>();

qeList .add(assetQueryEntity);
qeList .add(OTCQueryEntity);
qeList .add(SecurityQueryEntity);

CacheConfiguration cacheCfg = new CacheConfiguration<>("AssetCache");
cacheCfg.setQueryEntities(qeList);
IgniteCache cache = ignite.getOrCreateCache(cacheCfg);


The result is that I can see 3 tables with the right definition.
I can select data from OTC and SECURITY tables.
but the Asset table is empty

Is there a way to do that ?

Thanks for your help



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: QueryEntity and inheritence

Posted by Andrey Mashenkov <an...@gmail.com>.
Hi,

No views are supported.



On Fri, Mar 16, 2018 at 5:23 PM, ralph <ra...@gmail.com> wrote:

> Hi,
>
> I put OTC and Security objects into the same cache and it is splitted into
> 2
> tables which is actualy what i wanted.
>
> But also want to have a third table which would be a vue with all objects
> in
> the cache (Security and OTC)
> whith only common attributes which I understand is not supported.
>
>
> Thanks for your reply.
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>



-- 
Best regards,
Andrey V. Mashenkov

Re: QueryEntity and inheritence

Posted by ralph <ra...@gmail.com>.
Hi,

I put OTC and Security objects into the same cache and it is splitted into 2
tables which is actualy what i wanted.

But also want to have a third table which would be a vue with all objects in
the cache (Security and OTC) 
whith only common attributes which I understand is not supported.


Thanks for your reply.




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: QueryEntity and inheritence

Posted by Andrey Mashenkov <an...@gmail.com>.
Hi Ralf,

As I understand you put OTC objects and Security object into cache
and except that query to Assets will return all of these objects as Assets
class is parent to OTC and Security.

This is not supported. In Ignite, you will have 3 tables, one per value
object class.

As a workaround, you can try to split there entries and use joins, but sql
INSERTs into 2 tables will lose atomicity guaranty
as SQL doesn't supports transactions until MVCC will be implemented (until
ignite 2.5 version hopefully).


On Thu, Mar 15, 2018 at 11:37 PM, Ralph Benchetrit <
ralph.benchetrit@gmail.com> wrote:

> Up
>
> >
> > Hi,
> >
> > I have some objects that I want to put in an ignite cache and also want
> to
> > query them using jdbc sql.
> > I have used QueryEntity to define the mapping between object model and
> > relational model.
> >
> > My problem is :
> >
> > My objects uses inheritence.
> > "Asset" object is the parent, and "OTC" object and "Security" Object
> inherit
> > from Asset.
> >
> > Asset
> > |-OTC
> > |-Security
> >
> > I would like to have an sql model that is represented with 3 tables
> > ASSET table which will contain all attributs from Asset Object
> > OTC table which will contain all specialized attributs from OTC Object
> > SECURITY table which will contain all specialized attributs from Security
> > object
> >
> > And of course all data from 3 tables have to be mapped on the same cache
> (I
> > do not want to duplicate data in 2 caches)
> >
> > Here is what I have done:
> >
> > assetQueryEntity, OTCQueryEntity, SecurityQueryEntity are QueryEntity
> > definition for each of the 3 tables :
> >
> > LinkedList<QueryEntity> qeList = new LinkedList<>();
> >
> > qeList .add(assetQueryEntity);
> > qeList .add(OTCQueryEntity);
> > qeList .add(SecurityQueryEntity);
> >
> > CacheConfiguration cacheCfg = new CacheConfiguration<>("AssetCache");
> > cacheCfg.setQueryEntities(qeList);
> > IgniteCache cache = ignite.getOrCreateCache(cacheCfg);
> >
> >
> > The result is that I can see 3 tables with the right definition.
> > I can select data from OTC and SECURITY tables.
> > but the Asset table is empty
> >
> > Is there a way to do that ?
> >
> > Thanks for your help
> >
> >
> >
> > --
> > Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>
>


-- 
Best regards,
Andrey V. Mashenkov

Re: QueryEntity and inheritence

Posted by Ralph Benchetrit <ra...@gmail.com>.
Up

> 
> Hi,
> 
> I have some objects that I want to put in an ignite cache and also want to
> query them using jdbc sql.
> I have used QueryEntity to define the mapping between object model and
> relational model.
> 
> My problem is :
> 
> My objects uses inheritence.
> "Asset" object is the parent, and "OTC" object and "Security" Object inherit
> from Asset.
> 
> Asset
> |-OTC
> |-Security
> 
> I would like to have an sql model that is represented with 3 tables
> ASSET table which will contain all attributs from Asset Object
> OTC table which will contain all specialized attributs from OTC Object
> SECURITY table which will contain all specialized attributs from Security
> object
> 
> And of course all data from 3 tables have to be mapped on the same cache (I
> do not want to duplicate data in 2 caches)
> 
> Here is what I have done:
> 
> assetQueryEntity, OTCQueryEntity, SecurityQueryEntity are QueryEntity
> definition for each of the 3 tables :
> 
> LinkedList<QueryEntity> qeList = new LinkedList<>();
> 
> qeList .add(assetQueryEntity);
> qeList .add(OTCQueryEntity);
> qeList .add(SecurityQueryEntity);
> 
> CacheConfiguration cacheCfg = new CacheConfiguration<>("AssetCache");
> cacheCfg.setQueryEntities(qeList);
> IgniteCache cache = ignite.getOrCreateCache(cacheCfg);
> 
> 
> The result is that I can see 3 tables with the right definition.
> I can select data from OTC and SECURITY tables.
> but the Asset table is empty
> 
> Is there a way to do that ?
> 
> Thanks for your help
> 
> 
> 
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/