Foros de discusión

Extending liferay users in an other database

Charaf faceofjock, modificado hace 10 años.

Extending liferay users in an other database

Junior Member Mensajes: 30 Fecha de incorporación: 8/04/13 Mensajes recientes
Hi community ,

Please i realy need your help because i spent a lot of time trying to solve this problem .

I would like to develop several portlets that add students and teachers,main informations of student should be in table users_ of liferay, and add more fields in a custom Students table.
I followed this tutorial Herebut I do not understand how liferay is doing the joint between the users_ table and extension table (column :email)
Now that we have added addUser to our new class, when our class is called it will add a user to the liferay user table as well as our extra fields to our new table, and they will be linked via the e-mail address.
.
Can someone help me to do this task.

I will be very grateful.
Sunil Kulkarni, modificado hace 10 años.

RE: Extending liferay users in an other database

Junior Member Mensajes: 94 Fecha de incorporación: 24/06/11 Mensajes recientes
Hello,

LR does not support one-to-one mapping between 2 tables (joins) directly with Service Builder.

In one of my earlier assignment, I did the following. In my case I have used use id to map the data between 2 tables.

User_ table - LR table (userid - unique id)
UserExt table - Create by Me (userId -PK for my table).

1. Written a addUser method in my class.
2. Get the parameter required for adding user in LR and more parameters for populating the data in my table (UserExt).
3. Add a user in LR table usinf UserServiceUtil.addUser() method. Return type of this method is User model.
4. User User.userId from LR and also populate the data in UserExt table with User.userId as PK. So that when I get userId, I am able to get the information from both the tables with one unique key.
Charaf faceofjock, modificado hace 10 años.

RE: Extending liferay users in an other database

Junior Member Mensajes: 30 Fecha de incorporación: 8/04/13 Mensajes recientes
Thank you emoticon
Do you know how to get the current userId that is inserted into database?because i need to add it in the UserExta Table
thumbnail
Manish Yadav, modificado hace 10 años.

RE: Extending liferay users in an other database

Expert Mensajes: 493 Fecha de incorporación: 26/05/12 Mensajes recientes
did you create any custom portlet for adding user in portal or you are using OTB portlet..
If OTB then you can create EXT ..
from com.liferay.portlet.login.action.CreateAccountAction.java you can get

long userId=User.getUserid();
Charaf faceofjock, modificado hace 10 años.

RE: Extending liferay users in an other database

Junior Member Mensajes: 30 Fecha de incorporación: 8/04/13 Mensajes recientes
I have created a custom portlet that add user in user_ table and other fields in an other table userExtra.Any solution for this issue ?
Charaf faceofjock, modificado hace 10 años.

RE: Extending liferay users in an other database

Junior Member Mensajes: 30 Fecha de incorporación: 8/04/13 Mensajes recientes
SOLVED: UserLocalServiceUtil.addUser(...) return a User Object and from this object i got the last userId inserted in user_ table.

Thanks for your reply