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
inactivePlayers = manager.executeQuery(query); | |
System.out.println("There are " + inactivePlayers.size() + " inactive players now."); // should be zero |
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
manager.executeDelete(query); |
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
final QueryCriteria criteria = new QueryCriteria("active", QueryCriteriaOperator.EQUAL, false); | |
final Query query = new Query(Player.class, criteria); |
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
public static void main(String[] args) throws EntityException{ | |
// Create a database and its connection | |
PersistenceManagerFactory factory = new EmbeddedPersistenceManagerFactory(); //1 | |
factory.setCredentials("onyx", "SavingDataisFun!"); //2 | |
String pathToOnyxDB = System.getProperty("user.home") | |
+ File.separatorChar + ".onyxdb" | |
+ File.separatorChar + "sandbox" |
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
// Create a database and its connection | |
PersistenceManagerFactory factory = new EmbeddedPersistenceManagerFactory(); //1 | |
factory.setCredentials("onyx", "SavingDataisFun!"); //2 | |
String pathToOnyxDB = System.getProperty("user.home") | |
+ File.separatorChar + ".onyxdb" | |
+ File.separatorChar + "sandbox" | |
+ File.separatorChar +"model-update-db.oxd"; | |
factory.setDatabaseLocation(pathToOnyxDB); //3 |
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
// Fetch an account. Notice that the id is now a long rather than an integer. | |
Account account = (Account)persistenceManager.findById(Account.class, 1l); | |
assert account.getAccountId() == 1l; | |
// The Account Name is a new field and is now persistable. | |
// This demonstrates that we can now take | |
// advantage of the new field. | |
account.setAccountName("Utility Bill"); | |
persistenceManager.saveEntity(account); |
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 Account extends ManagedEntity implements IManagedEntity | |
{ | |
// Note, I have changed the type of the accountId from an int to a long. Also the generator was removed. | |
@Attribute | |
@Identifier | |
protected long accountId; | |
// Note, I have added the Account Holder's Name attribute | |
@Attribute |
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
Account account = new Account(); | |
account.setAccountName("Timbob's Lawn Care"); | |
account.setBalanceDue(55.43f); | |
Invoice marchLawnInvoice = new Invoice(); | |
marchLawnInvoice.setDueDate(parseDate("04-01-2016")); | |
marchLawnInvoice.setInvoiceDate(parseDate("03-01-2016")); | |
marchLawnInvoice.setNotes("Why did we need to mow your lawn. Its basically a dirt field."); | |
marchLawnInvoice.setInvoiceId(1l); | |
marchLawnInvoice.setAmount(44.32); |
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 Payment extends ManagedEntity implements IManagedEntity | |
{ | |
@Attribute | |
@Identifier | |
protected long paymentId; | |
@Relationship(type = RelationshipType.ONE_TO_ONE, | |
inverse = "payments", | |
inverseClass = Invoice.class) |
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 Invoice extends ManagedEntity implements IManagedEntity | |
{ | |
@Attribute | |
@Identifier | |
protected Long invoiceId; | |
@Attribute | |
protected Date invoiceDate; |