Foros de discusión

Liferay Recaching.

Henry Ng, modificado hace 10 años.

Liferay Recaching.

Junior Member Mensajes: 29 Fecha de incorporación: 21/04/13 Mensajes recientes
I am currently having a add profile portlet , there is no problem adding into the mysql database.
However when you are trying to display it . You would have to restart the server.
I read that it got something to do with lifeRay caching database entity at the start of running the server. Then use it.
Is there anyway to ask the Liferay to recache(the particular table) again after we updated data into the database?
thumbnail
Apoorva Prakash, modificado hace 10 años.

RE: Liferay Recaching.

Liferay Master Mensajes: 658 Fecha de incorporación: 15/06/10 Mensajes recientes
Henry Ng:
I am currently having a add profile portlet , there is no problem adding into the mysql database.
However when you are trying to display it . You would have to restart the server.
I read that it got something to do with lifeRay caching database entity at the start of running the server. Then use it.
Is there anyway to ask the Liferay to recache(the particular table) again after we updated data into the database?


Hello Henry,

If you are using service builder, this problem should not come! Are you sure?

HTH.

Thanks and Regerds,
Apoorva Prakash
Henry Ng, modificado hace 10 años.

RE: Liferay Recaching.

Junior Member Mensajes: 29 Fecha de incorporación: 21/04/13 Mensajes recientes
Hi

By service builder , you meant going into the service.xml file pressing the build service ,
then going into localserviceImpl to add in addStudent method then build service again

I am using eclipse ide btw.
thumbnail
mohammad azaruddin, modificado hace 10 años.

RE: Liferay Recaching.

Expert Mensajes: 492 Fecha de incorporación: 17/09/12 Mensajes recientes
Hi
It would be helpfull if you attach ERROR LOG here
Henry Ng, modificado hace 10 años.

RE: Liferay Recaching.

Junior Member Mensajes: 29 Fecha de incorporación: 21/04/13 Mensajes recientes
Which log do you need?

Because if you check in mysql the table would have data that is just inputted.
thumbnail
mohammad azaruddin, modificado hace 10 años.

RE: Liferay Recaching.

Expert Mensajes: 492 Fecha de incorporación: 17/09/12 Mensajes recientes
We need not to restart the server is you want to display the stored data in database...

but if you delete/add data to database externally (ie not via programing or by using mySqlQuery browser ) then u need to clear the database cache.(control panel>server administation>clear database cache),
Henry Ng, modificado hace 10 años.

RE: Liferay Recaching.

Junior Member Mensajes: 29 Fecha de incorporación: 21/04/13 Mensajes recientes
I added using a method found in StudentLocalServiceUtil
thumbnail
mohammad azaruddin, modificado hace 10 años.

RE: Liferay Recaching.

Expert Mensajes: 492 Fecha de incorporación: 17/09/12 Mensajes recientes
yeah that is right way to add..and you are making me confuse....can you explain your requirment bit clearly..?
thumbnail
mohammad azaruddin, modificado hace 10 años.

RE: Liferay Recaching.

Expert Mensajes: 492 Fecha de incorporación: 17/09/12 Mensajes recientes
Hi suggest you to practice LIA find E-Book here
Henry Ng, modificado hace 10 años.

RE: Liferay Recaching.

Junior Member Mensajes: 29 Fecha de incorporación: 21/04/13 Mensajes recientes
This is the code I use to Add into database

public void addStudent(String name , int gender , String email , String description ) throws com.liferay.portal.kernel.exception.SystemException 
	{
	  	    
		    Student tempstu =  StudentLocalServiceUtil.createStudent(CounterLocalServiceUtil.increment());
		   
		    tempstu.setDescription(description);
		    tempstu.setName(name);
		    tempstu.setGender(gender);
		    tempstu.setEmail(email);
	
		    StudentLocalServiceUtil.updateStudent(tempstu);
	    
	}


Method I use to display

Display Profile
<br>
<br>
Select a student:
&lt;% 
		try
		 {
			 int index = 1;
			 int count = StudentLocalServiceUtil.getStudentsCount();
			 List<student> studentList = StudentLocalServiceUtil.getStudents(0,count);
			 for (Student tempStudent : studentList)
			 {
				 String tempName=tempStudent.getName();
			
%&gt;		 
				<br>
				<form action="${displayProUrl}" method="post">
				<aui:input type="hidden" name="redirectURL" value="<%= renderResponse.createRenderURL().toString() %>" /> 
				<input type="radio" name="name" value="<%out.print(tempName);%>">&lt;%out.print(tempName);%&gt;
				
				
&lt;% 
				index++;
			 }
%&gt;
			 <br>
			 <input type="submit" value="Select">  
			 </form> 
	
&lt;% 	 	}
		catch(Exception e)
		{
			 e.printStackTrace();
		}

%&gt;
</student>




For example I add test

before in the database

After in the database

What it look like

After restart server


Is it because of this method I created in studentLocalServiceImpl.java
public void addStudent(String name , int gender , String email , String description ) throws com.liferay.portal.kernel.exception.SystemException 
	{
	  	    
		    Student tempstu =  StudentLocalServiceUtil.createStudent(CounterLocalServiceUtil.increment());
		   
		    tempstu.setDescription(description);
		    tempstu.setName(name);
		    tempstu.setGender(gender);
		    tempstu.setEmail(email);
	
		    StudentLocalServiceUtil.updateStudent(tempstu);
	    
	}
thumbnail
Apoorva Prakash, modificado hace 10 años.

RE: Liferay Recaching.

Liferay Master Mensajes: 658 Fecha de incorporación: 15/06/10 Mensajes recientes
Henry Ng:
This is the code I use to Add into database

public void addStudent(String name , int gender , String email , String description ) throws com.liferay.portal.kernel.exception.SystemException 
	{
	  	    
		    Student tempstu =  StudentLocalServiceUtil.createStudent(CounterLocalServiceUtil.increment());
		   
		    tempstu.setDescription(description);
		    tempstu.setName(name);
		    tempstu.setGender(gender);
		    tempstu.setEmail(email);
	
		    StudentLocalServiceUtil.updateStudent(tempstu);
	    
	}


Method I use to display

Display Profile
<br>
<br>
Select a student:
&lt;% 
		try
		 {
			 int index = 1;
			 int count = StudentLocalServiceUtil.getStudentsCount();
			 List<student> studentList = StudentLocalServiceUtil.getStudents(0,count);
			 for (Student tempStudent : studentList)
			 {
				 String tempName=tempStudent.getName();
			
%&gt;		 
				<br>
				<form action="${displayProUrl}" method="post">
				<aui:input type="hidden" name="redirectURL" value="<%= renderResponse.createRenderURL().toString() %>" /> 
				<input type="radio" name="name" value="<%out.print(tempName);%>">&lt;%out.print(tempName);%&gt;
				
				
&lt;% 
				index++;
			 }
%&gt;
			 <br>
			 <input type="submit" value="Select">  
			 </form> 
	
&lt;% 	 	}
		catch(Exception e)
		{
			 e.printStackTrace();
		}

%&gt;
</student>




For example I add test

before in the database

After in the database

What it look like

After restart server


Is it because of this method I created in studentLocalServiceImpl.java
public void addStudent(String name , int gender , String email , String description ) throws com.liferay.portal.kernel.exception.SystemException 
	{
	  	    
		    Student tempstu =  StudentLocalServiceUtil.createStudent(CounterLocalServiceUtil.increment());
		   
		    tempstu.setDescription(description);
		    tempstu.setName(name);
		    tempstu.setGender(gender);
		    tempstu.setEmail(email);
	
		    StudentLocalServiceUtil.updateStudent(tempstu);
	    
	}


Your code seems to be correct and it is not because you have written this method in studentLocalServiceImpl.java because this is correct approach.