Skip to content

Instantly share code, notes, and snippets.

View cosbor11's full-sized avatar
🤓
always coding

Chris Osborn cosbor11

🤓
always coding
View GitHub Profile
@cosbor11
cosbor11 / console
Last active August 17, 2016 21:27
mvn exec java
java -jar target/onyx-database-server-1.0.1.jar
@cosbor11
cosbor11 / pom.xml
Last active August 16, 2016 15:44
onyx remote database client pom
<groupId>com.onyxdevtools.samples</groupId>
<artifactId>onyx-database-client</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.onyxdevtools</groupId>
<artifactId>onyx-remote-driver</artifactId>
<version>${onyx-database.version}</version>
</dependency>
@cosbor11
cosbor11 / Main.java
Created October 20, 2015 09:09
onyx database remote persistence manager usage
PersistenceManagerFactory factory = new RemotePersistenceManagerFactory();
factory.setCredentials("onyx-remote", "SavingDataIsFun!");
factory.setDatabaseLocation("onx://localhost:8080");
factory.initialize();
PersistenceManager manager = factory.getPersistenceManager();
@Entity
public class Sailboat
{
@Identifier
@Attribute
protected String registrationCode;
@Attribute
protected String name;
@Entity
public class Skipper
{
@Identifier(generator = IdentifierGenerator.SEQUENCE)
@Attribute
protected long id;
@Attribute
protected String firstName;
// Create a new sailboat named Wind Passer and Registration(Primary Key) NCC1701
Sailboat sailboat = new Sailboat();
sailboat.setRegistrationCode("NCC1701");
sailboat.setName("Wind Passer");
// Create a new Skipper named Martha McFly
Skipper sailboatSkipper = new Skipper();
sailboatSkipper.setFirstName("Martha");
sailboatSkipper.setLastName("McFly");
manager.saveEntity(sailboat);
System.out.println("Created a new Sailboat " + sailboatSkipper.getSailboat().getName() + " with Skipper " + sailboatSkipper.getFirstName());
Sailboat newlyCreatedSailboat = manager.findWithId("NCC1701");
System.out.println("Sailboat " + newlyCreatedSailboat.getName() + " was created with skipper" + newlyCreatedSailboat.getSkipper().getFirstName());
@Entity
public class Sailboat
{
@Identifier
@Attribute
protected String registrationCode;
@Attribute
protected String name;
@Entity
public class CrewMember
{
@Identifier(generator = IdentifierGenerator.SEQUENCE)
@Attribute
public long id;
@Attribute
public String firstName;