掲示板
How to retrive the data from the database
11年前 に anand gopalan によって更新されました。
How to retrive the data from the database
Expert 投稿: 442 参加年月日: 12/03/02 最新の投稿
Hi,
How to retrive the data from the User_ table.
Enviornment:
Database: MySQL5.5
Liferay - IDE - Ecplise
Liferay6.1.0
Field Name:
UserId, firstname, lastname,middlename,screenname emailaddress
Condition: select userID,firstname,lastname,middlename,screenname,emailaddress from user_ where emailaddress="test@liferay.com";
User id is Primary Key.
Please let me how to do with service.xml or any other way. Please give me suggestion or code.
Regards
Anand
How to retrive the data from the User_ table.
Enviornment:
Database: MySQL5.5
Liferay - IDE - Ecplise
Liferay6.1.0
Field Name:
UserId, firstname, lastname,middlename,screenname emailaddress
Condition: select userID,firstname,lastname,middlename,screenname,emailaddress from user_ where emailaddress="test@liferay.com";
User id is Primary Key.
Please let me how to do with service.xml or any other way. Please give me suggestion or code.
Regards
Anand
11年前 に Jignesh Vachhani によって更新されました。
RE: How to retrive the data from the database
Liferay Master 投稿: 803 参加年月日: 08/03/10 最新の投稿
Use Dyamic query concept here to retrive data as per your query.
You can see details about dynamic query on below links :
http://www.liferay.com/community/forums/-/blogs/3813353/maximized
http://www.liferay.com/community/wiki/-/wiki/1071674/Dynamic+Query+API/maximized
You can see details about dynamic query on below links :
http://www.liferay.com/community/forums/-/blogs/3813353/maximized
http://www.liferay.com/community/wiki/-/wiki/1071674/Dynamic+Query+API/maximized
11年前 に anand gopalan によって更新されました。
RE: How to retrive the data from the database
Expert 投稿: 442 参加年月日: 12/03/02 最新の投稿
Hi Jignesh,
do you have any example to use dyanmic query, I found some examples in Liferay Forum, But all are
store the data from the form and display.
But requirement is I don't store the data from the Form, Already I have table I want to fetch the record and display in view.jsp
For example: User_ table in MySql, I want to get the record and display in view.jsp.
Please help.
Regards
Anand
do you have any example to use dyanmic query, I found some examples in Liferay Forum, But all are
store the data from the form and display.
But requirement is I don't store the data from the Form, Already I have table I want to fetch the record and display in view.jsp
For example: User_ table in MySql, I want to get the record and display in view.jsp.
Please help.
Regards
Anand
11年前 に Harish Kumar によって更新されました。
RE: How to retrive the data from the database
Expert 投稿: 483 参加年月日: 10/07/31 最新の投稿com.liferay.portal.model.User getUserByEmailAddress(long companyId, java.lang.String emailAddress)
11年前 に anand gopalan によって更新されました。
RE: How to retrive the data from the database
Expert 投稿: 442 参加年月日: 12/03/02 最新の投稿
Hello Harish,
where to write the above code, I didn't create any java code.
I created only view.jsp.
Please give me the step to achieve my task.
Please give ur guideance
Regards
Anand
where to write the above code, I didn't create any java code.
I created only view.jsp.
Please give me the step to achieve my task.
Please give ur guideance
Regards
Anand
11年前 に Jignesh Vachhani によって更新されました。
RE: How to retrive the data from the database
Liferay Master 投稿: 803 参加年月日: 08/03/10 最新の投稿
Anand,
You can use scriptlet in your jsp and the method which Harish suggested will return user object and from that user object you can get all metadata of user.
You can use scriptlet in your jsp and the method which Harish suggested will return user object and from that user object you can get all metadata of user.
11年前 に Harish Kumar によって更新されました。
RE: How to retrive the data from the database
Expert 投稿: 483 参加年月日: 10/07/31 最新の投稿anand gopalan:
Hello Harish,
where to write the above code, I didn't create any java code.
I created only view.jsp.
Please give me the step to achieve my task.
Please give ur guideance
Regards
Anand
Here is sample code-
User user = UserLocalServiceUtil.getUserByEmailAddress(companyId, emailAddress);
// call getters
String firstName = user.getFirstName();
you can get the companyId from themeDisplay object.
Regards
11年前 に anand gopalan によって更新されました。
RE: How to retrive the data from the database
Expert 投稿: 442 参加年月日: 12/03/02 最新の投稿
Thank you so much Harish, for your code and I achieved that.
But things is User_ table is the Liferay table. so there will be set method will be defined but I created the employee table
now I want to fetch the record based on some condition. where I can write my set method & get method. give me the folder structure how to implement.
Please send your guideline. So will very very helpful. I new bee for Liferay.
regards
Anand
But things is User_ table is the Liferay table. so there will be set method will be defined but I created the employee table
now I want to fetch the record based on some condition. where I can write my set method & get method. give me the folder structure how to implement.
Please send your guideline. So will very very helpful. I new bee for Liferay.
regards
Anand
11年前 に Harish Kumar によって更新されました。
RE: How to retrive the data from the database
Expert 投稿: 483 参加年月日: 10/07/31 最新の投稿
How did you created the employee table.
If you want to develop your custom entity, you can make use of service builder. Its a code generation tool provided by Liferay.
You can find details of service builder with example here
Regards
If you want to develop your custom entity, you can make use of service builder. Its a code generation tool provided by Liferay.
You can find details of service builder with example here
Regards
11年前 に anand gopalan によって更新されました。
RE: How to retrive the data from the database
Expert 投稿: 442 参加年月日: 12/03/02 最新の投稿
Directly create and insert in mysql database.
can I use any condition like
select firstname,lastname,empId,emailaddress from User_ where firstname='karthik';
please........ reply.
can I use any condition like
select firstname,lastname,empId,emailaddress from User_ where firstname='karthik';
please........ reply.
11年前 に anand gopalan によって更新されました。
RE: How to retrive the data from the database
Expert 投稿: 442 参加年月日: 12/03/02 最新の投稿
Harish I saw the example but that is create & retrive the data via service builder but I want only retrive by custom entity.
11年前 に anand gopalan によって更新されました。
RE: How to retrive the data from the database
Expert 投稿: 442 参加年月日: 12/03/02 最新の投稿
Harish I am awating for your response.
11年前 に Harish Kumar によって更新されました。
RE: How to retrive the data from the database
Expert 投稿: 483 参加年月日: 10/07/31 最新の投稿
now I want to fetch the record based on some condition. where I can write my set method & get method. give me the folder structure how to implement.
As per this you also want to have settters. Could you please explain the exact requirement?
11年前 に anand gopalan によって更新されました。
RE: How to retrive the data from the database
Expert 投稿: 442 参加年月日: 12/03/02 最新の投稿
My Requirement
My Own Table Name: Employee
Database: Mysql
Field Name:
empId - Primary Key
employeeName
casualLeave
seekLeave
paidLeave
Query condition:
Select employeename,empId,casualLeave,seekleave,paidLeave from employee where empId='1010316';
I want display the result in View.jsp
Please help how to achieve this.
My Own Table Name: Employee
Database: Mysql
Field Name:
empId - Primary Key
employeeName
casualLeave
seekLeave
paidLeave
Query condition:
Select employeename,empId,casualLeave,seekleave,paidLeave from employee where empId='1010316';
I want display the result in View.jsp
Please help how to achieve this.
11年前 に anand gopalan によって更新されました。
RE: How to retrive the data from the database
Expert 投稿: 442 参加年月日: 12/03/02 最新の投稿
Harish, If you give the guideline today its really very very helpful for me.
11年前 に anand gopalan によって更新されました。
RE: How to retrive the data from the database
Expert 投稿: 442 参加年月日: 12/03/02 最新の投稿
Hello Harish, Did u get any Ideas?
11年前 に anand gopalan によって更新されました。
RE: How to retrive the data from the database
Expert 投稿: 442 参加年月日: 12/03/02 最新の投稿
any updates?
11年前 に anand gopalan によって更新されました。
RE: How to retrive the data from the database
Expert 投稿: 442 参加年月日: 12/03/02 最新の投稿
I created a new Portlet to display the data,
now I stuck up in, what to define in service.xml for retrival data. Please send your suggestion & help.
now I stuck up in, what to define in service.xml for retrival data. Please send your suggestion & help.
11年前 に anand gopalan によって更新されました。
RE: How to retrive the data from the database
Expert 投稿: 442 参加年月日: 12/03/02 最新の投稿
I define below code in service.xml and build the service.xml
<entity name="lportal" local-service="true" table="employee"
remote-service="true" data-source="myDatasource">
<column name="empId" type="long" primary="true"></column>
<column name="employeeName" type="String"></column>
<column name="casualLeave" type="long"></column>
<column name="seekLeave" type="long"></column>
<column name="paidLeave" type="long"></column>
</entity>
now please tell me how to display the employee details in view.jsp
<entity name="lportal" local-service="true" table="employee"
remote-service="true" data-source="myDatasource">
<column name="empId" type="long" primary="true"></column>
<column name="employeeName" type="String"></column>
<column name="casualLeave" type="long"></column>
<column name="seekLeave" type="long"></column>
<column name="paidLeave" type="long"></column>
</entity>
now please tell me how to display the employee details in view.jsp
11年前 に anand gopalan によって更新されました。
RE: How to retrive the data from the database
Expert 投稿: 442 参加年月日: 12/03/02 最新の投稿
which class i need to import in JSP to get Firstname, lastname,............................
Please send your input.
Please send your input.
11年前 に Jignesh Vachhani によって更新されました。
RE: How to retrive the data from the database
Liferay Master 投稿: 803 参加年月日: 08/03/10 最新の投稿Harish Kumar:
com.liferay.portal.model.User getUserByEmailAddress(long companyId, java.lang.String emailAddress)
Perfect solutions Harish
Anand , you can directly use the API suggested by Harish as its already available.
11年前 に Gaurav Jain によって更新されました。
RE: How to retrive the data from the database
Regular Member 投稿: 145 参加年月日: 11/01/31 最新の投稿
There are various methods in UserLocalServiceUtil.
Import this class in your jsp/java file and call the methods you would like :
- byEmail : com.liferay.portal.service.UserLocalServiceUtil.getUserByEmailAddress(long companyId, String emailAddress)
- byScreenName : com.liferay.portal.service.UserLocalServiceUtil.getUserByScreenName(long companyId, String screenName)
- byId : com.liferay.portal.service.UserLocalServiceUtil.getUser(long userId)
You can get companyId by themeDisplay object or by PortalUtil method:
com.liferay.portal.util.PortalUtil.getCompanyId(HttpServletRequest request)
Import this class in your jsp/java file and call the methods you would like :
- byEmail : com.liferay.portal.service.UserLocalServiceUtil.getUserByEmailAddress(long companyId, String emailAddress)
- byScreenName : com.liferay.portal.service.UserLocalServiceUtil.getUserByScreenName(long companyId, String screenName)
- byId : com.liferay.portal.service.UserLocalServiceUtil.getUser(long userId)
You can get companyId by themeDisplay object or by PortalUtil method:
com.liferay.portal.util.PortalUtil.getCompanyId(HttpServletRequest request)