Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
How to retrive the data from the database anand gopalan 3. Oktober 2012 05:45
RE: How to retrive the data from the database Jignesh Vachhani 3. Oktober 2012 05:59
RE: How to retrive the data from the database anand gopalan 5. Oktober 2012 02:41
RE: How to retrive the data from the database Harish Kumar 5. Oktober 2012 02:49
RE: How to retrive the data from the database anand gopalan 5. Oktober 2012 02:59
RE: How to retrive the data from the database Jignesh Vachhani 5. Oktober 2012 03:02
RE: How to retrive the data from the database Harish Kumar 5. Oktober 2012 03:05
RE: How to retrive the data from the database anand gopalan 5. Oktober 2012 04:02
RE: How to retrive the data from the database Harish Kumar 5. Oktober 2012 04:08
RE: How to retrive the data from the database anand gopalan 5. Oktober 2012 04:13
RE: How to retrive the data from the database anand gopalan 5. Oktober 2012 04:16
RE: How to retrive the data from the database anand gopalan 5. Oktober 2012 04:26
RE: How to retrive the data from the database Harish Kumar 5. Oktober 2012 04:36
RE: How to retrive the data from the database anand gopalan 5. Oktober 2012 04:57
RE: How to retrive the data from the database anand gopalan 5. Oktober 2012 05:08
RE: How to retrive the data from the database anand gopalan 5. Oktober 2012 05:49
RE: How to retrive the data from the database anand gopalan 8. Oktober 2012 01:48
RE: How to retrive the data from the database anand gopalan 8. Oktober 2012 02:16
RE: How to retrive the data from the database anand gopalan 8. Oktober 2012 05:18
RE: How to retrive the data from the database anand gopalan 8. Oktober 2012 05:33
RE: How to retrive the data from the database Jignesh Vachhani 5. Oktober 2012 03:00
RE: How to retrive the data from the database Gaurav Jain 5. Oktober 2012 03:05
anand gopalan
How to retrive the data from the database
3. Oktober 2012 05:45
Antwort

anand gopalan

Rang: Expert

Nachrichten: 403

Eintrittsdatum: 2. März 2012

Neue Beiträge

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
3. Oktober 2012 05:59
Antwort

Jignesh Vachhani

Rang: Liferay Master

Nachrichten: 780

Eintrittsdatum: 10. März 2008

Neue Beiträge

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
5. Oktober 2012 02:41
Antwort

anand gopalan

Rang: Expert

Nachrichten: 403

Eintrittsdatum: 2. März 2012

Neue Beiträge

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
5. Oktober 2012 02:49
Antwort

Harish Kumar

Rang: Expert

Nachrichten: 330

Eintrittsdatum: 31. Juli 2010

Neue Beiträge

1com.liferay.portal.model.User getUserByEmailAddress(long companyId, java.lang.String emailAddress)
anand gopalan
RE: How to retrive the data from the database
5. Oktober 2012 02:59
Antwort

anand gopalan

Rang: Expert

Nachrichten: 403

Eintrittsdatum: 2. März 2012

Neue Beiträge

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
5. Oktober 2012 03:00
Antwort

Jignesh Vachhani

Rang: Liferay Master

Nachrichten: 780

Eintrittsdatum: 10. März 2008

Neue Beiträge

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
5. Oktober 2012 03:02
Antwort

Jignesh Vachhani

Rang: Liferay Master

Nachrichten: 780

Eintrittsdatum: 10. März 2008

Neue Beiträge

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
5. Oktober 2012 03:05
Antwort

Gaurav Jain

Rang: Regular Member

Nachrichten: 141

Eintrittsdatum: 31. Januar 2011

Neue Beiträge

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
5. Oktober 2012 03:05
Antwort

Harish Kumar

Rang: Expert

Nachrichten: 330

Eintrittsdatum: 31. Juli 2010

Neue Beiträge

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
5. Oktober 2012 04:02
Antwort

anand gopalan

Rang: Expert

Nachrichten: 403

Eintrittsdatum: 2. März 2012

Neue Beiträge

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
5. Oktober 2012 04:08
Antwort

Harish Kumar

Rang: Expert

Nachrichten: 330

Eintrittsdatum: 31. Juli 2010

Neue Beiträge

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
5. Oktober 2012 04:13
Antwort

anand gopalan

Rang: Expert

Nachrichten: 403

Eintrittsdatum: 2. März 2012

Neue Beiträge

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
5. Oktober 2012 04:16
Antwort

anand gopalan

Rang: Expert

Nachrichten: 403

Eintrittsdatum: 2. März 2012

Neue Beiträge

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
5. Oktober 2012 04:26
Antwort

anand gopalan

Rang: Expert

Nachrichten: 403

Eintrittsdatum: 2. März 2012

Neue Beiträge

Harish I am awating for your response.
Harish Kumar
RE: How to retrive the data from the database
5. Oktober 2012 04:36
Antwort

Harish Kumar

Rang: Expert

Nachrichten: 330

Eintrittsdatum: 31. Juli 2010

Neue Beiträge

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
5. Oktober 2012 04:57
Antwort

anand gopalan

Rang: Expert

Nachrichten: 403

Eintrittsdatum: 2. März 2012

Neue Beiträge

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
5. Oktober 2012 05:08
Antwort

anand gopalan

Rang: Expert

Nachrichten: 403

Eintrittsdatum: 2. März 2012

Neue Beiträge

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
5. Oktober 2012 05:49
Antwort

anand gopalan

Rang: Expert

Nachrichten: 403

Eintrittsdatum: 2. März 2012

Neue Beiträge

Hello Harish, Did u get any Ideas?
anand gopalan
RE: How to retrive the data from the database
8. Oktober 2012 01:48
Antwort

anand gopalan

Rang: Expert

Nachrichten: 403

Eintrittsdatum: 2. März 2012

Neue Beiträge

any updates?
anand gopalan
RE: How to retrive the data from the database
8. Oktober 2012 02:16
Antwort

anand gopalan

Rang: Expert

Nachrichten: 403

Eintrittsdatum: 2. März 2012

Neue Beiträge

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
8. Oktober 2012 05:18
Antwort

anand gopalan

Rang: Expert

Nachrichten: 403

Eintrittsdatum: 2. März 2012

Neue Beiträge

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
8. Oktober 2012 05:33
Antwort

anand gopalan

Rang: Expert

Nachrichten: 403

Eintrittsdatum: 2. März 2012

Neue Beiträge

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

Please send your input.