Created
May 6, 2016 17:35
-
-
Save cosbor11/fbb30f009f5ae8b389d9f6db431cea54 to your computer and use it in GitHub Desktop.
Create a Spring Controller and Autowire the PersistenceManager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Controller | |
| public class MeetingController | |
| { | |
| // Persistence Manager injected by spring | |
| @Autowired | |
| protected PersistenceManager persistenceManager; | |
| /** | |
| * Simple method used to encapsulate the saving of a meeting. | |
| * @param meeting Meeting to persist | |
| */ | |
| public void saveMeeting(Meeting meeting) | |
| { | |
| try { | |
| persistenceManager.saveEntity(meeting); | |
| } catch (EntityException e) { | |
| // Log an error | |
| } | |
| } | |
| /** | |
| * Method used to aggregate all meetings at work that are | |
| * snoozers and are really hard to stay awake but, you still have | |
| * to pay attention because someone is going to call on you and ask | |
| * you a dumb question. | |
| * | |
| * @return A list of really boring meetings | |
| */ | |
| public List<Meeting> findBoringMeetings() | |
| { | |
| Query query = new Query(Meeting.class, new QueryCriteria("notes", QueryCriteriaOperator.CONTAINS, "Boring")); | |
| List<Meeting> boringMeetings = null; | |
| try { | |
| boringMeetings = persistenceManager.executeQuery(query); | |
| } catch (EntityException e) { | |
| // Log an error | |
| } | |
| return boringMeetings; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment