JPA init
This commit is contained in:
parent
3ac79e94d6
commit
b5b7b1abdf
|
@ -1,9 +1,10 @@
|
||||||
package org.gcube.application.geoportal.model;
|
package org.gcube.application.geoportal.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
|
|
||||||
|
@ -23,14 +24,15 @@ public class ArchiveDescriptor {
|
||||||
// content
|
// content
|
||||||
private String archiveLocation;
|
private String archiveLocation;
|
||||||
|
|
||||||
@OneToMany
|
@OneToMany(cascade=CascadeType.ALL, mappedBy="archive",fetch=FetchType.EAGER)
|
||||||
private ArrayList<AssociatedContent> attachments;
|
private ArrayList<AssociatedContent> attachments;
|
||||||
|
|
||||||
|
|
||||||
// meta
|
// meta
|
||||||
private String metadataID;
|
private String metadataID;
|
||||||
|
|
||||||
private Map<String,LayerDescriptor> layers;
|
@OneToMany(cascade=CascadeType.ALL, mappedBy="archive",fetch=FetchType.EAGER)
|
||||||
|
private ArrayList<LayerDescriptor> layers;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package org.gcube.application.geoportal.model;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class AssociatedContent {
|
public class AssociatedContent {
|
||||||
|
@ -20,5 +22,7 @@ public class AssociatedContent {
|
||||||
private String itemID;
|
private String itemID;
|
||||||
private String link;
|
private String link;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name="archive_uuid", nullable=false)
|
||||||
|
private ArchiveDescriptor archive;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,17 @@
|
||||||
package org.gcube.application.geoportal.model;
|
package org.gcube.application.geoportal.model;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.ManyToOne;
|
||||||
|
|
||||||
|
@Entity
|
||||||
public class LayerDescriptor {
|
public class LayerDescriptor {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private String uuid;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name="archive_uuid", nullable=false)
|
||||||
|
private ArchiveDescriptor archive;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import javax.persistence.EntityManager;
|
||||||
import javax.persistence.EntityManagerFactory;
|
import javax.persistence.EntityManagerFactory;
|
||||||
import javax.persistence.Persistence;
|
import javax.persistence.Persistence;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.gcube.application.geoportal.model.ArchiveDescriptor;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class Archives {
|
public class Archives {
|
||||||
|
@ -21,7 +21,9 @@ public class Archives {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void listExistent() {
|
public void listExistent() {
|
||||||
// EntityManager em = jpaResourceBean.getEMF().createEntityManager();
|
|
||||||
|
EntityManager em = getEMF().createEntityManager();
|
||||||
|
em.find(ArchiveDescriptor.class, "some");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,19 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
|
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
|
||||||
<persistence-unit name="archiveDB" transaction-type="RESOURCE_LOCAL">
|
<persistence-unit name="archiveDB" transaction-type="RESOURCE_LOCAL">
|
||||||
<class>org.gcube.application.geoportal.model.ArchiveDescriptor</class>
|
<class>org.gcube.application.geoportal.model.ArchiveDescriptor</class>
|
||||||
<class>org.gcube.application.geoportal.model.AssociatedContent</class>
|
<class>org.gcube.application.geoportal.model.AssociatedContent</class>
|
||||||
|
<class>org.gcube.application.geoportal.model.LayerDescriptor</class>
|
||||||
<properties>
|
<properties>
|
||||||
<property name="javax.persistence.jdbc.url" value="jdbc:derby:sample;create=true"/>
|
<property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:unit-testing-geona;create=true"/>
|
||||||
<property name="javax.persistence.jdbc.user" value="user"/>
|
<!-- <property name="javax.persistence.jdbc.user" value="user"/>
|
||||||
<property name="javax.persistence.jdbc.password" value="xxxx"/>
|
<property name="javax.persistence.jdbc.password" value="xxxx"/> -->
|
||||||
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
|
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
|
||||||
|
<property name="eclipselink.ddl-generation" value="create-or-extend-tables"/>
|
||||||
|
<property name="eclipselink.logging.logger" value="org.eclipse.persistence.logging.DefaultSessionLog"/>
|
||||||
|
<property name="eclipselink.logging.level" value="INFO"/>
|
||||||
</properties>
|
</properties>
|
||||||
</persistence-unit>
|
</persistence-unit>
|
||||||
|
</persistence>
|
Loading…
Reference in New Issue