-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
483 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.t34</groupId> | ||
<artifactId>Px100DataTest</artifactId> | ||
<version>0.1.0</version> | ||
|
||
<repositories> | ||
<repository> | ||
<id>Px100 Data GitHub Repo</id> | ||
<url>https://github.com/a-rog/px100data/raw/master/releases</url> | ||
</repository> | ||
</repositories> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<org.springframework.version>4.1.3.RELEASE</org.springframework.version> | ||
<java.target.version>1.8</java.target.version> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>${java.target.version}</source> | ||
<target>${java.target.version}</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.px100systems</groupId> | ||
<artifactId>px100-persistence</artifactId> | ||
<version>0.3.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.px100systems</groupId> | ||
<artifactId>ignite-storage</artifactId> | ||
<version>0.3.0</version> | ||
</dependency> | ||
<!--dependency> | ||
<groupId>com.px100systems</groupId> | ||
<artifactId>in-memory-jdbc-persistence</artifactId> | ||
<version>0.3.0</version> | ||
</dependency--> | ||
|
||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-core</artifactId> | ||
<version>${org.springframework.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-tx</artifactId> | ||
<version>${org.springframework.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-beans</artifactId> | ||
<version>${org.springframework.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-expression</artifactId> | ||
<version>${org.springframework.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context</artifactId> | ||
<version>${org.springframework.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context-support</artifactId> | ||
<version>${org.springframework.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-aop</artifactId> | ||
<version>${org.springframework.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
31 changes: 31 additions & 0 deletions
31
examples/Px100DataTest/src/main/java/com/t34/test/Main.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.t34.test; | ||
|
||
import com.px100systems.data.core.DataStorageException; | ||
import com.px100systems.data.core.DatabaseStorage; | ||
import com.px100systems.data.core.Transaction; | ||
import com.t34.test.entity.MyEntity; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.context.support.ClassPathXmlApplicationContext; | ||
import java.util.Date; | ||
import static com.px100systems.data.core.Criteria.*; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:config.xml"); | ||
DatabaseStorage ds = context.getBean("dataStorage", DatabaseStorage.class); | ||
|
||
try { | ||
Transaction tx = ds.transaction(0); | ||
MyEntity bean = new MyEntity(); | ||
bean.setDate(new Date()); | ||
bean.setText("Hello"); | ||
tx.insert(bean); | ||
tx.commit(); | ||
|
||
tx = tx.transaction(0); | ||
System.out.println(tx.findOne(MyEntity.class, not(isNull("id")))); | ||
} catch (DataStorageException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
examples/Px100DataTest/src/main/java/com/t34/test/entity/MyEntity.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.t34.test.entity; | ||
|
||
import com.px100systems.data.core.Entity; | ||
import com.px100systems.data.core.Index; | ||
import com.px100systems.util.serialization.SerializationDefinition; | ||
|
||
import java.io.Externalizable; | ||
import java.io.IOException; | ||
import java.io.ObjectInput; | ||
import java.io.ObjectOutput; | ||
import java.util.Date; | ||
|
||
public class MyEntity extends Entity implements Externalizable { | ||
private String text; | ||
private Date date; | ||
|
||
@Override | ||
public void writeExternal(ObjectOutput out) throws IOException { | ||
SerializationDefinition.get(getClass()).write(out, this); | ||
} | ||
|
||
@Override | ||
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { | ||
SerializationDefinition.get(getClass()).read(in, this); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "MyEntity{" + | ||
"date=" + date + | ||
", text='" + text + '\'' + | ||
'}'; | ||
} | ||
|
||
@Index | ||
public Date getDate() { | ||
return date; | ||
} | ||
|
||
public void setDate(Date date) { | ||
this.date = date; | ||
} | ||
|
||
public String getText() { | ||
return text; | ||
} | ||
|
||
public void setText(String text) { | ||
this.text = text; | ||
} | ||
} |
Oops, something went wrong.