Posts

Showing posts from September, 2018

ORVE WS (Dynamic) (11) Persisting retrieved records and other control information (3). Table creation

0. Introduction Now that the JPA entities have been defined in the  ximodante.sicres.multiclassjpa  package it is time to let JPA create tables for us in the database. This link has been followed 1. Creation of Tables in the schema Here is a simple class for this purpose 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 package ximodante . jpamanager ; import javax.persistence.EntityManager ; import javax.persistence.EntityManagerFactory ; import javax.persistence.Persistence ; public class JPATest { /** * @param args */ EntityManagerFactory emf = null ; EntityManager em = null ; /** * This is only for creating tables * @param args */ public static void main ( String [] args ) { // TODO Auto-generated method stub EntityManagerFactory emf = Persistence . createEntityManagerFactory ( "sicresh2" ); EntityManager em = emf ...

ORVE WS (Dynamic) (10) Persisting retrieved records and other control information (2). JPA definitions

Image
0. Introduction Up till now, the h2 database has been created and the schema SICRES30 too. Hibernate has been our JPA proposal. Our goals are: 1. Create the persistence.xml file 2. Supply the JPA annotations to the classes to persist 3. Create the TABLES in the schema SICRES30 1. Creating persistence.xml file As it is a Maven project, the persistence.xml fike should be created in the META-INF folder into the src/main/resources folder of our project Here is the source code. Note the references to our database location, h2 driver etc. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 <persistence 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" version= "2.1" > <persiste...