cancel
Showing results for 
Search instead for 
Did you mean: 

How do i find a customer Model by passing its PK?

Former Member
0 Kudos
 
Former Member
0 Kudos

moved from the yaas space

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

You could create an own Dao which extends from the DefaultGenericDao class. DefaultGenericDao class has already some .find() methods which you could use or create your own method.

Example code

 public class DefaultCustomerDao extends DefaultGenericDao<CustomerModel> {
 
     public DefaultCustomerDao() {
         super(CustomerModel._TYPECODE);
     }
 
     public Collection<CustomerModel> findByPk(final String pk) {
         final String builder = "SELECT {pk} FROM {YourItem} WHERE {pk} = ?pk";
 
         final FlexibleSearchQuery query = new FlexibleSearchQuery(builder);
         query.addQueryParameter("pk", pk);
 
         return getFlexibleSearchService().<CustomerModel>search(query).getResult();
     }
 }

Spring

 <alias name="defaultCustomerDao" alias="customerDao" />
 <bean id="defaultCustomerDao" class="com.example..impl.DefaultCustomerDao" />
bhavirisetty
Active Participant
0 Kudos

use (CustomerModel)modelService.get(PK.parse("pass-pk-here"))