Skip to content

Instantly share code, notes, and snippets.

@kravigupta
Created May 6, 2015 09:05
LibraryLocalServiceImpl file with method calling custom sql finder
package me.rkg.plugins.service.impl;
import java.util.List;
import me.rkg.plugins.model.Author;
import me.rkg.plugins.model.Book;
import me.rkg.plugins.service.base.LibraryLocalServiceBaseImpl;
/**
* The implementation of the library local service.
*
* <p>
* All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the {@link me.rkg.plugins.service.LibraryLocalService} interface.
*
* <p>
* This is a local service. Methods of this service will not have security checks based on the propagated JAAS credentials because this service can only be accessed from within the same VM.
* </p>
*
* @author Ravi Kumar Gupta
* @see me.rkg.plugins.service.base.LibraryLocalServiceBaseImpl
* @see me.rkg.plugins.service.LibraryLocalServiceUtil
*/
public class LibraryLocalServiceImpl extends LibraryLocalServiceBaseImpl {
/*
* NOTE FOR DEVELOPERS:
*
* Never reference this interface directly. Always use {@link me.rkg.plugins.service.LibraryLocalServiceUtil} to access the library local service.
*/
public List<Object> getBookDetailsByAuthorAndTitle(String authorName, String title){
List<Object[]> objects = libraryFinder.findByAuthorAndTitle(authorName, title, -1, -1);
for(Object[] objs : objects){
System.out.println(objs.length);
for(int i=0;i<objs.length;i++){
if(objs[i] instanceof Book){
System.out.println("Object is instance of Book");
}
if(objs[i] instanceof Author){
System.out.println("Object is instance of Author");
}
}
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment