initial commit
This commit is contained in:
1
model/.gitignore
vendored
Normal file
1
model/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
72
model/pom.xml
Normal file
72
model/pom.xml
Normal file
@ -0,0 +1,72 @@
|
||||
<?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>
|
||||
|
||||
<parent>
|
||||
<groupId>test</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>${revision}${sha1}${changelist}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>test-model</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cayenne</groupId>
|
||||
<artifactId>cayenne-lifecycle</artifactId>
|
||||
<version>${cayenne.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.cayenne.plugins</groupId>
|
||||
<artifactId>cayenne-maven-plugin</artifactId>
|
||||
<version>${cayenne.version}</version>
|
||||
<configuration>
|
||||
<map>${project.basedir}/src/main/resources/test/test.map.xml</map>
|
||||
<superPkg>test.cayenne.auto</superPkg>
|
||||
<dataSource>
|
||||
<driver>com.mysql.cj.jdbc.Driver</driver>
|
||||
<url>${env.JDBC_TEST_JDBCURL}</url>
|
||||
<username>root</username>
|
||||
<password>test</password>
|
||||
</dataSource>
|
||||
<dbImport>
|
||||
<defaultPackage>test.cayenne</defaultPackage>
|
||||
<catalog>
|
||||
<name>test</name>
|
||||
<excludeTable>databasechangelog.*</excludeTable>
|
||||
</catalog>
|
||||
</dbImport>
|
||||
<overwriteExisting>true</overwriteExisting>
|
||||
<meaningfulPk>true</meaningfulPk>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-cli</id>
|
||||
<goals>
|
||||
<!-- To perform reverse engineering, explicitly run 'mvn cayenne:cdbimport' -->
|
||||
<!-- To perform class generation, explicitly run 'mvn cayenne:cgen' -->
|
||||
<!-- Start up the modeler from the command-line 'mvn cayenne-modeler:run' -->
|
||||
<goal>cgen</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<!-- 3rdParty deps-->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</project>
|
9
model/src/main/java/test/cayenne/E1.java
Normal file
9
model/src/main/java/test/cayenne/E1.java
Normal file
@ -0,0 +1,9 @@
|
||||
package test.cayenne;
|
||||
|
||||
import test.cayenne.auto._E1;
|
||||
|
||||
public class E1 extends _E1 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
9
model/src/main/java/test/cayenne/E2.java
Normal file
9
model/src/main/java/test/cayenne/E2.java
Normal file
@ -0,0 +1,9 @@
|
||||
package test.cayenne;
|
||||
|
||||
import test.cayenne.auto._E2;
|
||||
|
||||
public class E2 extends _E2 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
131
model/src/main/java/test/cayenne/auto/_E1.java
Normal file
131
model/src/main/java/test/cayenne/auto/_E1.java
Normal file
@ -0,0 +1,131 @@
|
||||
package test.cayenne.auto;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cayenne.BaseDataObject;
|
||||
import org.apache.cayenne.exp.property.EntityProperty;
|
||||
import org.apache.cayenne.exp.property.ListProperty;
|
||||
import org.apache.cayenne.exp.property.PropertyFactory;
|
||||
import org.apache.cayenne.exp.property.StringProperty;
|
||||
|
||||
import test.cayenne.E2;
|
||||
|
||||
/**
|
||||
* Class _E1 was generated by Cayenne.
|
||||
* It is probably a good idea to avoid changing this class manually,
|
||||
* since it may be overwritten next time code is regenerated.
|
||||
* If you need to make any customizations, please use subclass.
|
||||
*/
|
||||
public abstract class _E1 extends BaseDataObject {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String ID_PK_COLUMN = "id";
|
||||
|
||||
public static final StringProperty<String> TEXT = PropertyFactory.createString("text", String.class);
|
||||
public static final EntityProperty<E2> E2 = PropertyFactory.createEntity("e2", E2.class);
|
||||
public static final ListProperty<E2> E2S = PropertyFactory.createList("e2s", E2.class);
|
||||
|
||||
protected String text;
|
||||
|
||||
protected Object e2;
|
||||
protected Object e2s;
|
||||
|
||||
public void setText(String text) {
|
||||
beforePropertyWrite("text", this.text, text);
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
beforePropertyRead("text");
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public void setE2(E2 e2) {
|
||||
setToOneTarget("e2", e2, true);
|
||||
}
|
||||
|
||||
public E2 getE2() {
|
||||
return (E2)readProperty("e2");
|
||||
}
|
||||
|
||||
public void addToE2s(E2 obj) {
|
||||
addToManyTarget("e2s", obj, true);
|
||||
}
|
||||
|
||||
public void removeFromE2s(E2 obj) {
|
||||
removeToManyTarget("e2s", obj, true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<E2> getE2s() {
|
||||
return (List<E2>)readProperty("e2s");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object readPropertyDirectly(String propName) {
|
||||
if(propName == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
switch(propName) {
|
||||
case "text":
|
||||
return this.text;
|
||||
case "e2":
|
||||
return this.e2;
|
||||
case "e2s":
|
||||
return this.e2s;
|
||||
default:
|
||||
return super.readPropertyDirectly(propName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePropertyDirectly(String propName, Object val) {
|
||||
if(propName == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
switch (propName) {
|
||||
case "text":
|
||||
this.text = (String)val;
|
||||
break;
|
||||
case "e2":
|
||||
this.e2 = val;
|
||||
break;
|
||||
case "e2s":
|
||||
this.e2s = val;
|
||||
break;
|
||||
default:
|
||||
super.writePropertyDirectly(propName, val);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream out) throws IOException {
|
||||
writeSerialized(out);
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
readSerialized(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeState(ObjectOutputStream out) throws IOException {
|
||||
super.writeState(out);
|
||||
out.writeObject(this.text);
|
||||
out.writeObject(this.e2);
|
||||
out.writeObject(this.e2s);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
super.readState(in);
|
||||
this.text = (String)in.readObject();
|
||||
this.e2 = in.readObject();
|
||||
this.e2s = in.readObject();
|
||||
}
|
||||
|
||||
}
|
131
model/src/main/java/test/cayenne/auto/_E2.java
Normal file
131
model/src/main/java/test/cayenne/auto/_E2.java
Normal file
@ -0,0 +1,131 @@
|
||||
package test.cayenne.auto;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cayenne.BaseDataObject;
|
||||
import org.apache.cayenne.exp.property.EntityProperty;
|
||||
import org.apache.cayenne.exp.property.ListProperty;
|
||||
import org.apache.cayenne.exp.property.PropertyFactory;
|
||||
import org.apache.cayenne.exp.property.StringProperty;
|
||||
|
||||
import test.cayenne.E1;
|
||||
|
||||
/**
|
||||
* Class _E2 was generated by Cayenne.
|
||||
* It is probably a good idea to avoid changing this class manually,
|
||||
* since it may be overwritten next time code is regenerated.
|
||||
* If you need to make any customizations, please use subclass.
|
||||
*/
|
||||
public abstract class _E2 extends BaseDataObject {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String ID_PK_COLUMN = "id";
|
||||
|
||||
public static final StringProperty<String> TEXT = PropertyFactory.createString("text", String.class);
|
||||
public static final EntityProperty<E1> E1 = PropertyFactory.createEntity("e1", E1.class);
|
||||
public static final ListProperty<E1> E1S = PropertyFactory.createList("e1s", E1.class);
|
||||
|
||||
protected String text;
|
||||
|
||||
protected Object e1;
|
||||
protected Object e1s;
|
||||
|
||||
public void setText(String text) {
|
||||
beforePropertyWrite("text", this.text, text);
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
beforePropertyRead("text");
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public void setE1(E1 e1) {
|
||||
setToOneTarget("e1", e1, true);
|
||||
}
|
||||
|
||||
public E1 getE1() {
|
||||
return (E1)readProperty("e1");
|
||||
}
|
||||
|
||||
public void addToE1s(E1 obj) {
|
||||
addToManyTarget("e1s", obj, true);
|
||||
}
|
||||
|
||||
public void removeFromE1s(E1 obj) {
|
||||
removeToManyTarget("e1s", obj, true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<E1> getE1s() {
|
||||
return (List<E1>)readProperty("e1s");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object readPropertyDirectly(String propName) {
|
||||
if(propName == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
switch(propName) {
|
||||
case "text":
|
||||
return this.text;
|
||||
case "e1":
|
||||
return this.e1;
|
||||
case "e1s":
|
||||
return this.e1s;
|
||||
default:
|
||||
return super.readPropertyDirectly(propName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writePropertyDirectly(String propName, Object val) {
|
||||
if(propName == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
switch (propName) {
|
||||
case "text":
|
||||
this.text = (String)val;
|
||||
break;
|
||||
case "e1":
|
||||
this.e1 = val;
|
||||
break;
|
||||
case "e1s":
|
||||
this.e1s = val;
|
||||
break;
|
||||
default:
|
||||
super.writePropertyDirectly(propName, val);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeObject(ObjectOutputStream out) throws IOException {
|
||||
writeSerialized(out);
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
readSerialized(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeState(ObjectOutputStream out) throws IOException {
|
||||
super.writeState(out);
|
||||
out.writeObject(this.text);
|
||||
out.writeObject(this.e1);
|
||||
out.writeObject(this.e1s);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readState(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
super.readState(in);
|
||||
this.text = (String)in.readObject();
|
||||
this.e1 = in.readObject();
|
||||
this.e1s = in.readObject();
|
||||
}
|
||||
|
||||
}
|
11
model/src/main/resources/test/cayenne-test.xml
Normal file
11
model/src/main/resources/test/cayenne-test.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<domain xmlns="http://cayenne.apache.org/schema/10/domain"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://cayenne.apache.org/schema/10/domain https://cayenne.apache.org/schema/10/domain.xsd"
|
||||
project-version="10">
|
||||
<map name="test"/>
|
||||
<node name="test-node"
|
||||
factory="org.apache.cayenne.configuration.server.JNDIDataSourceFactory" parameters="jdbc/mysql/test">
|
||||
<map-ref name="test"/>
|
||||
</node>
|
||||
</domain>
|
40
model/src/main/resources/test/test.map.xml
Normal file
40
model/src/main/resources/test/test.map.xml
Normal file
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<data-map xmlns="http://cayenne.apache.org/schema/10/modelMap"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://cayenne.apache.org/schema/10/modelMap https://cayenne.apache.org/schema/10/modelMap.xsd"
|
||||
project-version="10">
|
||||
<property name="defaultPackage" value="test.cayenne"/>
|
||||
<property name="defaultCatalog" value="test"/>
|
||||
<db-entity name="e1" catalog="test">
|
||||
<db-attribute name="e2_id" type="BIGINT" length="10"/>
|
||||
<db-attribute name="id" type="BIGINT" isPrimaryKey="true" isGenerated="true" isMandatory="true" length="10"/>
|
||||
<db-attribute name="text" type="LONGVARCHAR" length="65535"/>
|
||||
</db-entity>
|
||||
<db-entity name="e2" catalog="test">
|
||||
<db-attribute name="e1_id" type="BIGINT" length="10"/>
|
||||
<db-attribute name="id" type="BIGINT" isPrimaryKey="true" isGenerated="true" isMandatory="true" length="10"/>
|
||||
<db-attribute name="text" type="LONGVARCHAR" length="65535"/>
|
||||
</db-entity>
|
||||
<obj-entity name="E1" className="test.cayenne.E1" dbEntityName="e1">
|
||||
<obj-attribute name="text" type="java.lang.String" db-attribute-path="text"/>
|
||||
</obj-entity>
|
||||
<obj-entity name="E2" className="test.cayenne.E2" dbEntityName="e2">
|
||||
<obj-attribute name="text" type="java.lang.String" db-attribute-path="text"/>
|
||||
</obj-entity>
|
||||
<db-relationship name="e2" source="e1" target="e2">
|
||||
<db-attribute-pair source="e2_id" target="id"/>
|
||||
</db-relationship>
|
||||
<db-relationship name="e2s" source="e1" target="e2" toMany="true">
|
||||
<db-attribute-pair source="id" target="e1_id"/>
|
||||
</db-relationship>
|
||||
<db-relationship name="e1" source="e2" target="e1">
|
||||
<db-attribute-pair source="e1_id" target="id"/>
|
||||
</db-relationship>
|
||||
<db-relationship name="e1s" source="e2" target="e1" toMany="true">
|
||||
<db-attribute-pair source="id" target="e2_id"/>
|
||||
</db-relationship>
|
||||
<obj-relationship name="e2" source="E1" target="E2" deleteRule="Nullify" db-relationship-path="e2"/>
|
||||
<obj-relationship name="e2s" source="E1" target="E2" deleteRule="Deny" db-relationship-path="e2s"/>
|
||||
<obj-relationship name="e1" source="E2" target="E1" deleteRule="Nullify" db-relationship-path="e1"/>
|
||||
<obj-relationship name="e1s" source="E2" target="E1" deleteRule="Deny" db-relationship-path="e1s"/>
|
||||
</data-map>
|
Reference in New Issue
Block a user