third-party persistance and junction table

classic Classic list List threaded Threaded
3 messages Options
Bastien Durel Bastien Durel
Reply | Threaded
Open this post in threaded view
|

third-party persistance and junction table

Hello,

I have a junction table in my model, and used the web console to
generate ignite config and classes from my SQL database

-> There is a table user with id (long) and some data
-> There is a table role with id (long) and some data
-> There is a table user_role with user_id (fk) and role_id (fk)

Reading cache from table works, I can query ignite with jdbc and I get
my relations as expected.

But if I want to add a new relation, the query :
insert into "UserRoleCache".user_role(USER_ID, ROLE_ID) values(6003, 2)
is translated into this one, sent to postgresql :
UPDATE public.user_role SET  WHERE (user_id=$1 AND role_id=$2)

Which obviously is rejected.

The web console generated a cache for this table, with UserRole
& UserRoleKey types, which each contains userId and roleId Long's.

Is there a better (correct) way to handle these many-to-many relations
in ignite (backed by RDBMS) ?

Regards,

--
Bastien Durel
DATA
Intégration des données de l'entreprise,
Systèmes d'information décisionnels.

[hidden email]
tel : +33 (0) 1 57 19 59 28
fax : +33 (0) 1 57 19 59 73
12 avenue Raspail, 94250 GENTILLY France
www.data.fr

aealexsandrov aealexsandrov
Reply | Threaded
Open this post in threaded view
|

Re: third-party persistance and junction table

Hi,

Unfortunately, Ignite doesn't support such kind of relations out of the
box. Ignite just translates it to third party data storage that used as
cache-store.

It's expected that inserts and updates will be rejected in case if they
break some rules.

BR,
Andrei
7/21/2020 11:16 AM, Bastien Durel пишет:

> Hello,
>
> I have a junction table in my model, and used the web console to
> generate ignite config and classes from my SQL database
>
> -> There is a table user with id (long) and some data
> -> There is a table role with id (long) and some data
> -> There is a table user_role with user_id (fk) and role_id (fk)
>
> Reading cache from table works, I can query ignite with jdbc and I get
> my relations as expected.
>
> But if I want to add a new relation, the query :
> insert into "UserRoleCache".user_role(USER_ID, ROLE_ID) values(6003, 2)
> is translated into this one, sent to postgresql :
> UPDATE public.user_role SET  WHERE (user_id=$1 AND role_id=$2)
>
> Which obviously is rejected.
>
> The web console generated a cache for this table, with UserRole
> & UserRoleKey types, which each contains userId and roleId Long's.
>
> Is there a better (correct) way to handle these many-to-many relations
> in ignite (backed by RDBMS) ?
>
> Regards,
>
Bastien Durel Bastien Durel
Reply | Threaded
Open this post in threaded view
|

Re: third-party persistance and junction table

Hello,

OK, so I'll stick with my "dummy char(1) column as value" hack.

Thanks,

Le jeudi 23 juillet 2020 à 17:41 +0300, Andrei Aleksandrov a écrit :

> Hi,
>
> Unfortunately, Ignite doesn't support such kind of relations out of
> the
> box. Ignite just translates it to third party data storage that used
> as
> cache-store.
>
> It's expected that inserts and updates will be rejected in case if
> they
> break some rules.
>
> BR,
> Andrei
> 7/21/2020 11:16 AM, Bastien Durel пишет:
> > Hello,
> >
> > I have a junction table in my model, and used the web console to
> > generate ignite config and classes from my SQL database
> >
> > -> There is a table user with id (long) and some data
> > -> There is a table role with id (long) and some data
> > -> There is a table user_role with user_id (fk) and role_id (fk)
> >
> > Reading cache from table works, I can query ignite with jdbc and I
> > get
> > my relations as expected.
> >
> > But if I want to add a new relation, the query :
> > insert into "UserRoleCache".user_role(USER_ID, ROLE_ID)
> > values(6003, 2)
> > is translated into this one, sent to postgresql :
> > UPDATE public.user_role SET  WHERE (user_id=$1 AND role_id=$2)
> >
> > Which obviously is rejected.
> >
> > The web console generated a cache for this table, with UserRole
> > & UserRoleKey types, which each contains userId and roleId Long's.
> >
> > Is there a better (correct) way to handle these many-to-many
> > relations
> > in ignite (backed by RDBMS) ?
> >
> > Regards,
> >
--
Bastien Durel
DATA
Intégration des données de l'entreprise,
Systèmes d'information décisionnels.

[hidden email]
tel : +33 (0) 1 57 19 59 28
fax : +33 (0) 1 57 19 59 73
12 avenue Raspail, 94250 GENTILLY France
www.data.fr