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
| /** | |
| * IBAction for saving a person. This will create a save request with a new | |
| */ | |
| - (IBAction) savePerson:(id)sender | |
| { | |
| // Create a new Person | |
| Person *person = [Person new]; | |
| [person setFirstName:@"Bob"]; | |
| [person setLastName:@"Sanchez"]; | |
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
| package com.onyxdevtools.quickstart.entities; | |
| import com.onyx.persistence.ManagedEntity; | |
| import com.onyx.persistence.annotations.*; | |
| import java.util.Date; | |
| @Entity | |
| public class Person extends ManagedEntity | |
| { |
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
| <key>NSAppTransportSecurity</key> | |
| <dict> | |
| <key>NSAllowsArbitraryLoads</key><true/> | |
| </dict> |
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
| @Entity | |
| public class Actor | |
| { | |
| @Attribute | |
| @Identifier(generator = IdentifierGenerator.SEQUENCE) | |
| protected long actorId; | |
| @Attribute | |
| protected String actorFirstName; |
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
| @Entity | |
| public class Movie | |
| { | |
| @Identifier(generator = IdentifierGenerator.SEQUENCE) | |
| @Attribute | |
| protected long movieId; | |
| @Attribute | |
| protected String title; |
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
| // Define Harrison Ford Actor | |
| Actor harrisonFordActor = new Actor(); | |
| harrisonFordActor.setFirstName("Harrison"); | |
| harrisonFordActor.setLastName("Ford"); | |
| // Define Mark Hamill Actor | |
| Actor markHamillActor = new Actor(); | |
| markHamillActor.setFirstName("Mark"); | |
| markHamillActor.setLastName("Hamill"); |
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
| harrisonFordActor = persistenceManager.find(harrisonFordActor); | |
| persistenceManager.initialize(harrisonFordActor, "movies"); | |
| System.out.println("Harrison Ford has been in " | |
| + harrisonFordActor.getMovies().size() | |
| + " movies including " | |
| + harrisonFordActor.getMovies().get(0).getTitle() | |
| + " and " | |
| + harrisonFordActor.getMovies().get(1).getTitle() | |
| + "!"); |
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
| @Entity | |
| public class Movie extends ManagedEntity implements IManagedEntity | |
| { | |
| @Identifier(generator = IdentifierGenerator.SEQUENCE) | |
| @Attribute | |
| public int movieId; | |
| @Attribute | |
| public String title; |
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
| // Populate the movie data with actors //1 | |
| Movie starWarsMovie = new Movie(); | |
| starWarsMovie.title = "Star Wars, A new Hope"; | |
| ArrayList<Actor> actors = new ArrayList<>(); | |
| Actor markHamil = new Actor(); | |
| markHamil.actorId = 1; | |
| markHamil.firstName = "Mark"; | |
| markHamil.lastName = "Hamil"; |
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
| // The Persistence Manager did not save the actors and associated it to the movie //2 | |
| Movie starWarsAfterSave1 = (Movie) manager.findById(Movie.class, starWarsMovie.movieId); | |
| manager.initialize(starWarsAfterSave1, "actors"); | |
| if(starWarsAfterSave1.actors.size() == 0) { | |
| System.out.println("Actors have NOT been associated yet"); | |
| } |