-1

I plan on writing a query method like

/**
 * TODO Auto-generated method documentation
 * 
 * @param entity
 * @return EventExecute
 */
@Transactional
@Autowired
public EventExecute save(EventExecute entity) {
    String eventKey = entity.getEventKey();

    StepDefinitionRepository sdRepository;

    List<StepDefinition> stepDefinitions = sdRepository.findByEventKeyAllIgnoreCaseOrderBySequenceAsc(eventKey);

    return getEventExecuteRepository().save(entity);
}

I want to lookup the StepDefintions that match an event key.

I tried following the example in the JPA Documentation...

public class SomeClient {

  @Autowired
  private PersonRepository repository;

  public void doSomething() {
    List<Person> persons = repository.findByLastname("Matthews");
  }
}

But my sdRepository complains that is it not initialized. I found the getStepDefintionRepository() in the ..ServiceImpl.aj but can't call it.

Is there an example out there?

Neil Stockton
  • 11,383
  • 3
  • 34
  • 29
Mike Oliver
  • 71
  • 1
  • 7

1 Answers1

0

Ok I figured out my error...here is what works.

@Autowired
private StepDefinitionRepository sdRepository;

/**
 * Overridden save method to intercept and process the dynamic steps before saving
 * 
 * @param entity
 * @return EventExecute
 */
@Transactional
public EventExecute save(EventExecute entity) {

    boolean keepGoing = true;
    String eventKey = entity.getEventKey();
    Set<NameValuePair> messageVariables = null;
    String eventArguments = entity.getEventArguments();
    List<NameValuePair> eventVariables = null;

    if (!eventArguments.isEmpty()){
        eventVariables = _ExtractEventVariables(eventArguments);
    }

    List<StepDefinition> stepDefinitions = sdRepository.findByEventKeyAllIgnoreCaseOrderBySequenceAsc(eventKey);

    for (Iterator<StepDefinition> iterator = stepDefinitions.iterator(); iterator.hasNext();) {
Mike Oliver
  • 71
  • 1
  • 7