フォーラム

ホーム » Liferay Portal » English » 3. Development

構造的に表示 平面上に表示 ツリー上に表示
スレッド [ 前へ | 次へ ]
toggle
How to retrive the data from the database anand gopalan 2012/10/03 5:45
RE: How to retrive the data from the database Jignesh Vachhani 2012/10/03 5:59
RE: How to retrive the data from the database anand gopalan 2012/10/05 2:41
RE: How to retrive the data from the database Harish Kumar 2012/10/05 2:49
RE: How to retrive the data from the database anand gopalan 2012/10/05 2:59
RE: How to retrive the data from the database Jignesh Vachhani 2012/10/05 3:02
RE: How to retrive the data from the database Harish Kumar 2012/10/05 3:05
RE: How to retrive the data from the database anand gopalan 2012/10/05 4:02
RE: How to retrive the data from the database Harish Kumar 2012/10/05 4:08
RE: How to retrive the data from the database anand gopalan 2012/10/05 4:13
RE: How to retrive the data from the database anand gopalan 2012/10/05 4:16
RE: How to retrive the data from the database anand gopalan 2012/10/05 4:26
RE: How to retrive the data from the database Harish Kumar 2012/10/05 4:36
RE: How to retrive the data from the database anand gopalan 2012/10/05 4:57
RE: How to retrive the data from the database anand gopalan 2012/10/05 5:08
RE: How to retrive the data from the database anand gopalan 2012/10/05 5:49
RE: How to retrive the data from the database anand gopalan 2012/10/08 1:48
RE: How to retrive the data from the database anand gopalan 2012/10/08 2:16
RE: How to retrive the data from the database anand gopalan 2012/10/08 5:18
RE: How to retrive the data from the database anand gopalan 2012/10/08 5:33
RE: How to retrive the data from the database Jignesh Vachhani 2012/10/05 3:00
RE: How to retrive the data from the database Gaurav Jain 2012/10/05 3:05
anand gopalan
How to retrive the data from the database
2012/10/03 5:45
答え

anand gopalan

ランク: Expert

投稿: 401

参加年月日: 2012/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
Jignesh Vachhani
RE: How to retrive the data from the database
2012/10/03 5:59
答え

Jignesh Vachhani

ランク: Liferay Master

投稿: 780

参加年月日: 2008/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
anand gopalan
RE: How to retrive the data from the database
2012/10/05 2:41
答え

anand gopalan

ランク: Expert

投稿: 401

参加年月日: 2012/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
Harish Kumar
RE: How to retrive the data from the database
2012/10/05 2:49
答え

Harish Kumar

ランク: Expert

投稿: 327

参加年月日: 2010/07/31

最近の投稿

1com.liferay.portal.model.User getUserByEmailAddress(long companyId, java.lang.String emailAddress)
anand gopalan
RE: How to retrive the data from the database
2012/10/05 2:59
答え

anand gopalan

ランク: Expert

投稿: 401

参加年月日: 2012/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
Jignesh Vachhani
RE: How to retrive the data from the database
2012/10/05 3:00
答え

Jignesh Vachhani

ランク: Liferay Master

投稿: 780

参加年月日: 2008/03/10

最近の投稿

Harish Kumar:
1com.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.
Jignesh Vachhani
RE: How to retrive the data from the database
2012/10/05 3:02
答え

Jignesh Vachhani

ランク: Liferay Master

投稿: 780

参加年月日: 2008/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.
Gaurav Jain
RE: How to retrive the data from the database
2012/10/05 3:05
答え

Gaurav Jain

ランク: Regular Member

投稿: 141

参加年月日: 2011/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)
Harish Kumar
RE: How to retrive the data from the database
2012/10/05 3:05
答え

Harish Kumar

ランク: Expert

投稿: 327

参加年月日: 2010/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-

1
2User user = UserLocalServiceUtil.getUserByEmailAddress(companyId, emailAddress);
3// call getters
4String firstName = user.getFirstName();
5
6you can get the companyId from themeDisplay object.


Regards
anand gopalan
RE: How to retrive the data from the database
2012/10/05 4:02
答え

anand gopalan

ランク: Expert

投稿: 401

参加年月日: 2012/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
Harish Kumar
RE: How to retrive the data from the database
2012/10/05 4:08
答え

Harish Kumar

ランク: Expert

投稿: 327

参加年月日: 2010/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
anand gopalan
RE: How to retrive the data from the database
2012/10/05 4:13
答え

anand gopalan

ランク: Expert

投稿: 401

参加年月日: 2012/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.
anand gopalan
RE: How to retrive the data from the database
2012/10/05 4:16
答え

anand gopalan

ランク: Expert

投稿: 401

参加年月日: 2012/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.
anand gopalan
RE: How to retrive the data from the database
2012/10/05 4:26
答え

anand gopalan

ランク: Expert

投稿: 401

参加年月日: 2012/03/02

最近の投稿

Harish I am awating for your response.
Harish Kumar
RE: How to retrive the data from the database
2012/10/05 4:36
答え

Harish Kumar

ランク: Expert

投稿: 327

参加年月日: 2010/07/31

最近の投稿

1
2now 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?
anand gopalan
RE: How to retrive the data from the database
2012/10/05 4:57
答え

anand gopalan

ランク: Expert

投稿: 401

参加年月日: 2012/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.
anand gopalan
RE: How to retrive the data from the database
2012/10/05 5:08
答え

anand gopalan

ランク: Expert

投稿: 401

参加年月日: 2012/03/02

最近の投稿

Harish, If you give the guideline today its really very very helpful for me.
anand gopalan
RE: How to retrive the data from the database
2012/10/05 5:49
答え

anand gopalan

ランク: Expert

投稿: 401

参加年月日: 2012/03/02

最近の投稿

Hello Harish, Did u get any Ideas?
anand gopalan
RE: How to retrive the data from the database
2012/10/08 1:48
答え

anand gopalan

ランク: Expert

投稿: 401

参加年月日: 2012/03/02

最近の投稿

any updates?
anand gopalan
RE: How to retrive the data from the database
2012/10/08 2:16
答え

anand gopalan

ランク: Expert

投稿: 401

参加年月日: 2012/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.
anand gopalan
RE: How to retrive the data from the database
2012/10/08 5:18
答え

anand gopalan

ランク: Expert

投稿: 401

参加年月日: 2012/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
anand gopalan
RE: How to retrive the data from the database
2012/10/08 5:33
答え

anand gopalan

ランク: Expert

投稿: 401

参加年月日: 2012/03/02

最近の投稿

which class i need to import in JSP to get Firstname, lastname,............................

Please send your input.