jueves, 1 de junio de 2017

JavaEE JPA API Laboratorio



JPA Cases

Estos Son ejemplos prácticos de generación de tablas de bases de datos a partir de entidades (@Entity)  annotations en Java JPA

Enlace a archivo work con imagenes

JPA_1_Simple Table

@Entity
public class Tabla implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String nombre;
    private String apellido;
    private Double valDouble;
    private Integer valInteger;
    private boolean valboolean;
    @Temporal(DATE)
    private java.util.Date utilDate;
    private java.sql.Date sqlDate;
    private Time sqlTime;
    private Timestamp sqlTimeStamp;
    @Lob
    private String descripcion;
    @Lob
    @Column(name="EMP_PIC",columnDefinition="BLOB NOT NULL")
    private byte[] pic;
   
    public Long getId() {
        return id;
    } …

Genera


drop table DEVELOP.TABLA cascade constraints;

/*==============================================================*/
/* Table: TABLA                                                 */
/*==============================================================*/
create table DEVELOP.TABLA
(
   ID                   NUMBER(19)           not null,
   APELLIDO             VARCHAR2(255),
   DESCRIPCION          CLOB,
   NOMBRE               VARCHAR2(255),
   EMP_PIC              BLOB                 not null,
   SQLDATE              DATE,
   SQLTIME              TIMESTAMP,
   SQLTIMESTAMP         TIMESTAMP,
   UTILDATE             DATE,
   VALDOUBLE            NUMBER(19,4),
   VALINTEGER           NUMBER(10),
   VALBOOLEAN           NUMBER(1)            default 0,
   constraint SYS_C007261 primary key (ID)
         using index pctfree 10
   initrans 2
   storage
   (
       initial 64K
       next 1024K
       minextents 1
       maxextents unlimited
   )
   logging
   tablespace DEVELOP_TABSPACE
)
pctfree 10
initrans 1
storage
(
    initial 64K
    next 1024K
    minextents 1
    maxextents unlimited
)
tablespace DEVELOP_TABSPACE
logging
 nocompress
 lob
 (DESCRIPCION)
    store as
         basicfile
 (tablespace DEVELOP_TABSPACE
        chunk 8192
 retention nocache);

drop table DEVELOP.SEQUENCE cascade constraints;

/*==============================================================*/
/* Table: SEQUENCE                                              */
/*==============================================================*/
create table DEVELOP.SEQUENCE
(
   SEQ_NAME             VARCHAR2(50)         not null,
   SEQ_COUNT            NUMBER,
   constraint SYS_C007263 primary key (SEQ_NAME)
         using index pctfree 10
   initrans 2
   storage
   (
       initial 64K
       next 1024K
       minextents 1
       maxextents unlimited
   )
   logging
   tablespace DEVELOP_TABSPACE
)
pctfree 10
initrans 1
storage
(
    initial 64K
    next 1024K
    minextents 1
    maxextents unlimited
)
tablespace DEVELOP_TABSPACE
logging
 nocompress
 monitoring
 noparallel;

JPA_2_SimpleTable


@Entity
public class Tabla implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="TABLA_SEQ")
    @Column(name="TABLA_ID")
    private Long id;
    private String nombre;


drop table DEVELOP.TABLA cascade constraints;

/*==============================================================*/
/* Table: TABLA                                                 */
/*==============================================================*/
create table DEVELOP.TABLA
(
   TABLA_ID             NUMBER(19)           not null,
   APELLIDO             VARCHAR2(255),
   DESCRIPCION          CLOB,
   NOMBRE               VARCHAR2(255),
   EMP_PIC              BLOB                 not null,
   SQLDATE              DATE,
   SQLTIME              TIMESTAMP,
   SQLTIMESTAMP         TIMESTAMP,
   UTILDATE             DATE,
   VALDOUBLE            NUMBER(19,4),
   VALINTEGER           NUMBER(10),
   VALBOOLEAN           NUMBER(1)            default 0,
   constraint SYS_C007266 primary key (TABLA_ID)
         using index pctfree 10
   initrans 2
   storage
   (
       initial 64K
       next 1024K
       minextents 1
       maxextents unlimited
   )
   logging
   tablespace DEVELOP_TABSPACE
)
pctfree 10
initrans 1
storage
(
    initial 64K
    next 1024K
    minextents 1
    maxextents unlimited
)
tablespace DEVELOP_TABSPACE
logging
 nocompress
 lob
 (DESCRIPCION)
    store as
         basicfile
 (tablespace DEVELOP_TABSPACE
        chunk 8192
 retention nocache);

JPA_3_SimpleTable


@Entity
public class Tabla implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator="TABLA_GEN")
    @Column(name="TABLA_ID")
    private Long id;
    private String nombre;


drop table DEVELOP.TABLA cascade constraints;

/*==============================================================*/
/* Table: TABLA                                                 */
/*==============================================================*/
create table DEVELOP.TABLA
(
   TABLA_ID             NUMBER(19)           not null,
   APELLIDO             VARCHAR2(255),
   DESCRIPCION          CLOB,
   NOMBRE               VARCHAR2(255),
   EMP_PIC              BLOB                 not null,
   SQLDATE              DATE,
   SQLTIME              TIMESTAMP,
   SQLTIMESTAMP         TIMESTAMP,
   UTILDATE             DATE,
   VALDOUBLE            NUMBER(19,4),
   VALINTEGER           NUMBER(10),
   VALBOOLEAN           NUMBER(1)            default 0,
   constraint SYS_C007269 primary key (TABLA_ID)
         using index pctfree 10
   initrans 2
   storage
   (
       initial 64K
       next 1024K
       minextents 1
       maxextents unlimited
   )
   logging
   tablespace DEVELOP_TABSPACE
)
pctfree 10
initrans 1
storage
(
    initial 64K
    next 1024K
    minextents 1
    maxextents unlimited
)
tablespace DEVELOP_TABSPACE
logging
 nocompress
 lob
 (DESCRIPCION)
    store as
         basicfile
 (tablespace DEVELOP_TABSPACE
        chunk 8192
 retention nocache);

drop table DEVELOP.SEQUENCE cascade constraints;

/*==============================================================*/
/* Table: SEQUENCE                                              */
/*==============================================================*/
create table DEVELOP.SEQUENCE
(
   SEQ_NAME             VARCHAR2(50)         not null,
   SEQ_COUNT            NUMBER,
   constraint SYS_C007271 primary key (SEQ_NAME)
         using index pctfree 10
   initrans 2
   storage
   (
       initial 64K
       next 1024K
       minextents 1
       maxextents unlimited
   )
   logging
   tablespace DEVELOP_TABSPACE
)
pctfree 10
initrans 1
storage
(
    initial 64K
    next 1024K
    minextents 1
    maxextents unlimited
)
tablespace DEVELOP_TABSPACE
logging
 nocompress
 monitoring
 noparallel;

JPA_4_SimpleTableElemColl


@Entity
public class Tabla implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator="TABLA_GEN")
    @Column(name="TABLA_ID")
    private Long id;
    private String nombre;
    private String apellido;
    private Double valDouble;
    private Integer valInteger;
    private boolean valboolean;
    @Temporal(DATE)
    private java.util.Date utilDate;
    private java.sql.Date sqlDate;
    private Time sqlTime;
    private Timestamp sqlTimeStamp;
    @Lob
    private String descripcion;
    @Lob
    @Column(name="EMP_PIC",columnDefinition="BLOB NOT NULL")
    //@Column(name="EMP_PIC",columnDefinition="LONGBLOB NOT NULL") //en caso de MySQL
    private byte[] pic;
    @ElementCollection  //uses default table TABLA_ELEMCOLL
    @Column(name="DetalleTabla", length=50)
    private Set<String> ElemColl = new HashSet();


drop table DEVELOP.TABLA cascade constraints;

/*==============================================================*/
/* Table: TABLA                                                 */
/*==============================================================*/
create table DEVELOP.TABLA
(
   TABLA_ID             NUMBER(19)           not null,
   APELLIDO             VARCHAR2(255),
   DESCRIPCION          CLOB,
   NOMBRE               VARCHAR2(255),
   EMP_PIC              BLOB                 not null,
   SQLDATE              DATE,
   SQLTIME              TIMESTAMP,
   SQLTIMESTAMP         TIMESTAMP,
   UTILDATE             DATE,
   VALDOUBLE            NUMBER(19,4),
   VALINTEGER           NUMBER(10),
   VALBOOLEAN           NUMBER(1)            default 0,
   constraint SYS_C006999 primary key (TABLA_ID)
         using index pctfree 10
   initrans 2
   storage
   (
       initial 64K
       next 1024K
       minextents 1
       maxextents unlimited
   )
   logging
   tablespace DEVELOP_TABSPACE
)
pctfree 10
initrans 1
storage
(
    initial 64K
    next 1024K
    minextents 1
    maxextents unlimited
)
tablespace DEVELOP_TABSPACE
logging
 nocompress
 lob
 (DESCRIPCION)
    store as
         basicfile
 (tablespace DEVELOP_TABSPACE
        chunk 8192
 retention nocache);

alter table DEVELOP.TABLA_ELEMCOLL
   drop constraint TABLA_ELEMCOLL_TABLA_TABLA_ID;

drop table DEVELOP.TABLA_ELEMCOLL cascade constraints;

/*==============================================================*/
/* Table: TABLA_ELEMCOLL                                        */
/*==============================================================*/
create table DEVELOP.TABLA_ELEMCOLL
(
   TABLA_TABLA_ID       NUMBER(19),
   DETALLETABLA         VARCHAR2(50)
)
pctfree 10
initrans 1
storage
(
    initial 64K
    next 1024K
    minextents 1
    maxextents unlimited
)
tablespace DEVELOP_TABSPACE
logging
 nocompress
 monitoring
 noparallel;

alter table DEVELOP.TABLA_ELEMCOLL
   add constraint TABLA_ELEMCOLL_TABLA_TABLA_ID foreign key (TABLA_TABLA_ID)
      references DEVELOP.TABLA (TABLA_ID)
      not deferrable;

drop table DEVELOP.SEQUENCE cascade constraints;

/*==============================================================*/
/* Table: SEQUENCE                                              */
/*==============================================================*/
create table DEVELOP.SEQUENCE
(
   SEQ_NAME             VARCHAR2(50)         not null,
   SEQ_COUNT            NUMBER,
   constraint SYS_C007002 primary key (SEQ_NAME)
         using index pctfree 10
   initrans 2
   storage
   (
       initial 64K
       next 1024K
       minextents 1
       maxextents unlimited
   )
   logging
   tablespace DEVELOP_TABSPACE
)
pctfree 10
initrans 1
storage
(
    initial 64K
    next 1024K
    minextents 1
    maxextents unlimited
)
tablespace DEVELOP_TABSPACE
logging
 nocompress
 monitoring
 noparallel;

En caso de MySQL

drop table if exists wsp.tabla;

/*==============================================================*/
/* Table: tabla                                                 */
/*==============================================================*/
create table wsp.tabla
(
   TABLA_ID             bigint(20) not null,
   APELLIDO             national varchar(255),
   DESCRIPCION          national longtext,
   NOMBRE               national varchar(255),
   EMP_PIC              longblob not null,
   SQLDATE              date,
   SQLTIME              time,
   SQLTIMESTAMP         datetime,
   UTILDATE             date,
   VALDOUBLE            double,
   VALINTEGER           int(11),
   VALBOOLEAN           tinyint(1) default 0,
   primary key (TABLA_ID)
);

drop table if exists wsp.tabla_elemcoll;

/*==============================================================*/
/* Table: tabla_elemcoll                                        */
/*==============================================================*/
create table wsp.tabla_elemcoll
(
   Tabla_TABLA_ID       bigint(20),
   DetalleTabla         national varchar(50)
);

alter table wsp.tabla_elemcoll add constraint FK_Tabla_ELEMCOLL_Tabla_TABLA_ID foreign key (Tabla_TABLA_ID)
      references wsp.tabla (TABLA_ID);

drop table if exists wsp.sequence;

/*==============================================================*/
/* Table: sequence                                              */
/*==============================================================*/
create table wsp.sequence
(
   SEQ_NAME             national varchar(50) not null,
   SEQ_COUNT            decimal(38,0),
   primary key (SEQ_NAME)
);

JPA Relationships


ManyToOne Mappings


Employee(Many)   Department(One)

@Entity
public class Employee implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String name;
    private Long salary;
    @ManyToOne
    private Department department;
   
}

@Entity
public class Department implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String name;
   
}

DB scripts from Entity classes…

CREATE TABLE EMPLOYEE (ID NUMBER(19) NOT NULL, NAME VARCHAR2(255) NULL, SALARY NUMBER(19) NULL, DEPARTMENT_ID NUMBER(19) NULL, PRIMARY KEY (ID))
CREATE TABLE DEPARTMENT (ID NUMBER(19) NOT NULL, NAME VARCHAR2(255) NULL, PRIMARY KEY (ID))
ALTER TABLE EMPLOYEE ADD CONSTRAINT FK_EMPLOYEE_DEPARTMENT_ID FOREIGN KEY (DEPARTMENT_ID) REFERENCES DEPARTMENT (ID)
CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR2(50) NOT NULL, SEQ_COUNT NUMBER(38) NULL, PRIMARY KEY (SEQ_NAME))
INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values ('SEQ_GEN', 0)


ManyToOne JoinColumn


@Entity
public class Employee implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String name;
    private Long salary;
    @ManyToOne
    @JoinColumn(name="DEPT_ID")
    private Department department;
   
}

@Entity
public class Department implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String name;
   
}

CREATE TABLE EMPLOYEE (ID NUMBER(19) NOT NULL, NAME VARCHAR2(255) NULL, SALARY NUMBER(19) NULL, DEPT_ID NUMBER(19) NULL, PRIMARY KEY (ID))
CREATE TABLE DEPARTMENT (ID NUMBER(19) NOT NULL, NAME VARCHAR2(255) NULL, PRIMARY KEY (ID))
ALTER TABLE EMPLOYEE ADD CONSTRAINT FK_EMPLOYEE_DEPT_ID FOREIGN KEY (DEPT_ID) REFERENCES DEPARTMENT (ID)
CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR2(50) NOT NULL, SEQ_COUNT NUMBER(38) NULL, PRIMARY KEY (SEQ_NAME))
INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values ('SEQ_GEN', 0)


OneToOne Mappings


Employee (one) --- ParkingSpace (one)
@Entity
public class Employee implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String name;
    private Long salary;
    @OneToOne
    @JoinColumn(name="PSPACE_ID")
    private ParkingSpace parkingSpace;
   
}

@Entity
public class ParkingSpace implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private int lot;
    private String location;
   
}

CREATE TABLE EMPLOYEE (ID NUMBER(19) NOT NULL, NAME VARCHAR2(255) NULL, SALARY NUMBER(19) NULL, PSPACE_ID NUMBER(19) NULL, PRIMARY KEY (ID))
CREATE TABLE PARKINGSPACE (ID NUMBER(19) NOT NULL, LOCATION VARCHAR2(255) NULL, LOT NUMBER(10) NULL, PRIMARY KEY (ID))
ALTER TABLE EMPLOYEE ADD CONSTRAINT FK_EMPLOYEE_PSPACE_ID FOREIGN KEY (PSPACE_ID) REFERENCES PARKINGSPACE (ID)
CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR2(50) NOT NULL, SEQ_COUNT NUMBER(38) NULL, PRIMARY KEY (SEQ_NAME))
INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values ('SEQ_GEN', 0)

Check that the foreing key must have a uniqueness constraint, and it doesn’t happen. So in case of MySQL is added manually the constraint
ALTER TABLE EMPLOYEE ADD UNIQUE PARKINGSPACECONSTRAINT (DEPT_ID);
In Oracle
ALTER TABLE EMPLOYEE ADD CONTRAINT PARKINGSPACECONSTRAINT UNIQUE (DEPT_ID)
When populate with data test report an error of duplicates.

OneToOne Bidirectional


@Entity
public class Employee implements Serializable { 
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String name;
    private Long salary;
    @OneToOne
    @JoinColumn(name="PSPACE_ID")
    private ParkingSpace parkingSpace;

@Entity
public class ParkingSpace implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private int lot;
    private String location;
    @OneToOne(mappedBy="parkingSpace")
    private Employee employee;

CREATE TABLE EMPLOYEE (ID NUMBER(19) NOT NULL, NAME VARCHAR2(255) NULL, SALARY NUMBER(19) NULL, PSPACE_ID NUMBER(19) NULL, PRIMARY KEY (ID))
CREATE TABLE PARKINGSPACE (ID NUMBER(19) NOT NULL, LOCATION VARCHAR2(255) NULL, LOT NUMBER(10) NULL, PRIMARY KEY (ID))
ALTER TABLE EMPLOYEE ADD CONSTRAINT FK_EMPLOYEE_PSPACE_ID FOREIGN KEY (PSPACE_ID) REFERENCES PARKINGSPACE (ID)
CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR2(50) NOT NULL, SEQ_COUNT NUMBER(38) NULL, PRIMARY KEY (SEQ_NAME))
INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values ('SEQ_GEN', 0)

The generated script is the same as the OneToOne unidirection relation???

OneToMany


Employee (many) ---- Department (one)
@Entity
public class Employee implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String name;
    private Long salary;
    private Department department;
   
}

@Entity
public class Department implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String name;
    @OneToMany(cascade=CascadeType.PERSIST,mappedBy="department") //(fetch=FetchType.LAZY, cascade=CascadeType.PERSIST)
    private List<Employee> employees = new ArrayList<Employee>();
    
}

Script generated for MySQL:
CREATE TABLE EMPLOYEE (ID BIGINT NOT NULL, NAME VARCHAR(255), SALARY BIGINT, DEPARTMENT_ID BIGINT, PRIMARY KEY (ID))
CREATE TABLE DEPARTMENT (ID BIGINT NOT NULL, NAME VARCHAR(255), PRIMARY KEY (ID))
ALTER TABLE EMPLOYEE ADD CONSTRAINT FK_EMPLOYEE_DEPARTMENT_ID FOREIGN KEY (DEPARTMENT_ID) REFERENCES DEPARTMENT (ID)
CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(38), PRIMARY KEY (SEQ_NAME))
INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values ('SEQ_GEN', 0)

OneToMany Version 2


@Entity
public class Employee implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE,generator="EMPLOYEE_GEN")
    @Column(name="EMP_ID")
    private Long id;
    private String name;
    private Long salary;
    @ManyToOne(targetEntity=Department.class, fetch=FetchType.LAZY)
    private Department department;
   
}

@Entity
public class Department implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE,generator="DEPARTMENT_GEN")
    @Column(name="DEP_ID")
    private Long id;
    private String name;
    @OneToMany(cascade=CascadeType.ALL,mappedBy="department") //(fetch=FetchType.LAZY, cascade=CascadeType.PERSIST)
    private List<Employee> employees = new ArrayList<Employee>();
    
}

MySQL script:


ManyToMany with out CascadeType.Persist


@Entity
public class Employee implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    //@GeneratedValue(strategy = GenerationType.TABLE,generator="EMP_TAB")
    //@TableGenerator(name="EMP_TAB",table="EMP_GEN")
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name="EMP_ID")
    private Long id;
    private String name;
    private Long salary;
    @ManyToMany//(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
    @JoinTable(name="EMP_PROJ",
            joinColumns=@JoinColumn(name="EMP_ID"),
            inverseJoinColumns=@JoinColumn(name="PROJ_ID"))
    private List<Project> projects = new ArrayList<Project>();
  
}

@Entity
public class Project implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    //@GeneratedValue(strategy = GenerationType.TABLE,generator="PROJ_TAB")
    //@TableGenerator(name="PROJ_TAB",table="PROJ_GEN")
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name="PROJ_ID")
    private Long id;
    private String name;
    @ManyToMany(mappedBy="projects")
    private List<Employee> employees = new ArrayList<Employee>();
   
}

public class Populate {

    public static void main(String... args) {
        EntityManagerFactory emf = createEntityManagerFactory("JPArelationshipsPU");
        EntityManager em = emf.createEntityManager();
        populate(emf);
        emf.close();
    }
   
    private static void populate(EntityManagerFactory emf) {
        EntityManager em = emf.createEntityManager();
       
        Employee emp = new Employee();
        emp.setName("Un Empleado");
        emp.setSalary(1203L);
       
        Employee emp2 = new Employee();
        emp2.setName("Empleado Dos");
        emp2.setSalary(77777L);
       
        Employee emp3 = new Employee();
        emp3.setName("Empleado sin Departamento");
        emp3.setSalary(9999L);
              
        Project proj = new Project();
        proj.setName("Projecto ONE");
       
        Project proj2 = new Project();
        proj2.setName("Projecto X");
              
        emp.getProjects().add(proj);
        emp.getProjects().add(proj2);
       
        emp2.getProjects().add(proj2);
       
        proj.getEmployees().add(emp2);
        proj2.getEmployees().add(emp);
       
        em.getTransaction().begin();
        em.persist(emp);
        em.persist(emp2);
        em.persist(proj);          // Without PERSIST this is necesary
        em.persist(proj2);       // Withoiut PERSIST this is necesary
        em.getTransaction().commit();
        //em.flush();  
        em.close();
    }



If only is PERSISTED the employee with out CascadeType.PERSIST and not is PERSISTED the project the following error will throws:
[EL Warning]: java.lang.IllegalStateException: During synchronization a new object was found through a relationship that was not marked cascade PERSIST: org.jamr.model.Project[ id=null ].
Exception in thread "main" javax.persistence.RollbackException: java.lang.IllegalStateException: During synchronization a new object was found through a relationship that was not marked cascade PERSIST: org.jamr.model.Project[ id=null ].
                at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:157)
                at com.jamr.example.Populate.populate(Populate.java:63)
                at com.jamr.example.Populate.main(Populate.java:25)
Caused by: java.lang.IllegalStateException: During synchronization a new object was found through a relationship that was not marked cascade PERSIST: org.jamr.model.Project[ id=null ].
                at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.discoverUnregisteredNewObjects(RepeatableWriteUnitOfWork.java:310)
                at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.calculateChanges(UnitOfWorkImpl.java:723)
                at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1516)
                at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:277)
                at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1169)
                at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:132)
                ... 2 more

Otherwise with employee with CascadeType.PERSIST, is not necessary Persist de project. Is automatically persisted by his relationship marked with employee.

viernes, 26 de mayo de 2017

Congifurar Oracle 11gEX


*** Mensajes al instalar Oracle 11g
Destination Folder: C:\oraclexe\
Oracle Home: C:\oraclexe\app\oracle\product\11.2.0\server\
Oracle Base:C:\oraclexe\
Port for 'Oracle Database Listener': 1521
Port for 'Oracle Services for Microsoft Transaction Server': 2030
Port for 'Oracle HTTP Listener': 8080

*** obtenidos del registry ORACLE_HOME=C:\oraclexe\app\oracle\product\11.2.0\server
***                 ORACLE_SID=XE

Se creará un usuario "develop" y schema  "DEVELOP" para hacer desarrollo

*** creacion de usuario y schema
https://stackoverflow.com/questions/18403125/how-to-create-a-new-schema-new-user-in-oracle-11g


create user
SQL> create user develop identified by betopass;

verifying

SQL> select username from dba_users;

USERNAME
------------------------------
DEVELOP
SYS
SYSTEM
ANONYMOUS
APEX_PUBLIC_USER
FLOWS_FILES
APEX_040000
OUTLN
DIP
ORACLE_OCM
XS$NULL

USERNAME
------------------------------
MDSYS
CTXSYS
DBSNMP
XDB
APPQOSSYS
HR

17 rows selected.

If you try to login as develop now you would get an error:

ERROR:
ORA-01045: user JOHNY lacks CREATE SESSION privilege; logon denied

SQL> connect
Enter user-name: system
Enter password:
Connected.
SQL> grant create session to develop;

Grant succeeded.

To get rid of the user you can drop it:

SQL> drop user johny;

Show already created tablespaces:

SQL> select tablespace_name from dba_tablespaces;
Create tablespace:

SQL> create tablespace johny_tabspace
  2  datafile 'johny_tabspace.dat'
  3  size 10M autoextend on;

Create temporary tablespace (Temporaty tablespace is an allocation of space in the database that can contain transient data that persists only for the duration of a session. This transient data cannot be recovered after process or instance failure.):

SQL> create temporary tablespace johny_tabspace_temp
  2  tempfile 'johny_tabspace_temp.dat'
  3  size 5M autoextend on;

Create de user develop

SQL> create user develop identified by betopass
  2  default tablespace develop_tabspace
  3  temporary tablespace develop_tabspace_temp;

User created.

Grant some privileges

SQL> grant create session to develop;

Grant succeeded.

SQL> grant create table to develop;

Grant succeeded.

SQL> grant unlimited tablespace to develop;

Grant succeeded.

SQL> grant create sequence to develop;


------------------------------------------------------
---- scripts resumidos y adaptados para usuario develop
create tablespace develop_tabspace
datafile 'develop_tabspace.dat'
size 10M autoextend on;

create temporaty tablespace develop_tabspace_temp
tempfile 'develop_tabspace_temp.dat'
size 5M autoextend on;

create user develop identified by betopass
default tablespace develop_tabspace
temporary tablespace develop_tabspace_temp;

grant create session to develop;
grant create table to develop;
grant unlimited tablespace to develop;
grant create sequence to develop;


------------------------------------------------------


login as develop and check what privileges he has

SQL> connect
Enter user-name: develop
Enter password:
Connected.
SQL> select * from session_privs;

PRIVILEGE
----------------------------------------
CREATE SESSION
UNLIMITED TABLESPACE
CREATE TABLE

SQL>
SQL> create table dev_table
  2  (
  3  id int not null,
  4  text varchar2(1000),
  5  primary key (id)
  6  );

Table created.

SQL> insert into dev_table (id, text) values (1,'esto es un dato de prueba');

1 row created.

SQL> select * from dev_table;

        ID
----------
TEXT
--------------------------------------------------------------------------------
         1
esto es un dato de prueba

To get DDL data you can use DBMS_METADATA package that "provides a way for you to retrieve metadata from the database dictionary as XML or creation DDL and to submit the XML to re-create the object.". (with help from http://www.dba-oracle.com/oracle_tips_dbms_metadata.htm)

For table:

SQL> set pagesize 0
SQL> set long 90000
SQL> set feedback off
SQL> set echo off
SQL> SELECT DBMS_METADATA.GET_DDL('TABLE',u.table_name) FROM USER_TABLES u;
Result:
 CREATE TABLE "JOHNY"."JOHNY_TABLE"
   (    "ID" NUMBER(*,0) NOT NULL ENABLE,
        "TEXT" VARCHAR2(1000),
         PRIMARY KEY ("ID")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DE
FAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "JOHNY_TABSPACE"  ENABLE
   ) SEGMENT CREATION IMMEDIATE
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DE
FAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "JOHNY_TABSPACE"

For index:

SQL> set pagesize 0
SQL> set long 90000
SQL> set feedback off
SQL> set echo off
SQL> SELECT DBMS_METADATA.GET_DDL('INDEX',u.index_name) FROM USER_INDEXES u;
Result:

  CREATE UNIQUE INDEX "JOHNY"."SYS_C0013353" ON "JOHNY"."JOHNY_TABLE" ("ID")
  PCTFREE 10 INITRANS 2 MAXTRANS 255
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DE
FAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "JOHNY_TABSPACE"
More information:

DDL

http://docs.oracle.com/cd/B12037_01/server.101/b10759/statements_1001.htm
DBMS_METADATA

http://www.dba-oracle.com/t_1_dbms_metadata.htm
http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_metada.htm#ARPLS026
http://docs.oracle.com/cd/B28359_01/server.111/b28310/general010.htm#ADMIN11562
Schema objects

http://docs.oracle.com/cd/B19306_01/server.102/b14220/schema.htm
Differences between schema and user

https://dba.stackexchange.com/questions/37012/difference-between-database-vs-user-vs-schema
Difference between a user and a schema in Oracle?
Privileges

http://docs.oracle.com/cd/E11882_01/timesten.112/e21642/privileges.htm#TTSQL338
Creating user/schema

http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_8003.htm
http://www.techonthenet.com/oracle/schemas/create_schema.php
Creating tablespace

http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_7003.htm#i2231734
SQL Plus commands

http://ss64.com/ora/syntax-sqlplus.html


***** ERRORS ***********

---------------------------------
> sqlplus /nolog

SQL> connect / as sysdba

Connected.

SQL> shutdown abort

ORACLE Instance shut down.

SQL> startup nomount

ORACLE Instance started

SQL> alter database mount;

SQL> alter database open;

-----------------------------------------

"ORA-00205: error in identifying controlfile"

What is the best way to re-create control file in the correct format and store it in the right place?

Answer:

The oerr utility show this for the ORA-00205 error:

ORA-00205: error in identifying control file, check alert log for more info

Cause: The system could not find a control file of the specified name and size.

Action: Check that ALL control files are online and that they are the same files that the system created at cold start time.

Your database must be shutdown first. (And probably it is not working right now.)

First of all, create pfile from spfile by issuing this command:

SQL> create pfile from spfile;

Then look under the directory of $ORACLE_HOME\database. You will find a newly created pfile. (Its name is init<SID>.ora) Edit newly created pfile to correct controlfile locations. Then issue the command below:

SQL> create spfile from pfile;

After that, database will see controlfiles. But if you also have changed datafile locations; you have to rename datafiles in mount mode.

If you have lost only one of many control files, the procedure is different.  It is a standard practice to have at least two control file (normally three), so you need to identify the surviving control files and replace the missing one with one of the others.

--------------------------------------------------------------------------------------



You are installing on an unsupported operating system and something could go wrong.

The file initSID.ora, where SID is the instance name (XE in your case), is the initialization parameter file (pfile) which Oracle uses when instance starts to load its runtime settings specified by database administrator.

For some reason the installation process was not successful, and you end up with the default pfile named init.ora.

On startup Oracle instance reads initialization parameters from the following files in the order of appearance

    spfileSID.ora
    spfile.ora
    initSID.ora

where the first two being binary counterparts of pfiles and are called server parameter files (spfiles), because they should reside on the server side in contrast to pfiles which can be on any side.

You can copy init.ora to initXE.ora and set appropriate parameters just to check if your instance starts.

However you would better try reinstalling your database checking the messages shown in the output during installation to see if something goes wrong or using supported OS.

------------------------------------------------------------------------------------------

---- SOLVED ---

SQL> connect / as sysdba
Connected.

SQL> show parameter contr

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string      C:\ORACLEXE\APP\ORACLE\ORADATA
                                                 \XE\CONTROL.DBF
control_management_pack_access       string      NONE
SQL>

SQL> create pfile='C:\Users\Bext\Documents\JPAtutorial\pfile.ora' from spfile;

File created.

----- The pfile.ora -------------------
xe.__db_cache_size=327155712
xe.__java_pool_size=4194304
xe.__large_pool_size=12582912
xe.__oracle_base='C:\oraclexe\app\oracle'#ORACLE_BASE set from environment
xe.__pga_aggregate_target=432013312
xe.__sga_target=641728512
xe.__shared_io_pool_size=100663296
xe.__shared_pool_size=184549376
xe.__streams_pool_size=0
*.audit_file_dest='C:\oraclexe\app\oracle\admin\XE\adump'
*.compatible='11.2.0.0.0'
*.control_files='C:\oraclexe\app\oracle\oradata\XE\control.dbf'
*.db_name='XE'
*.DB_RECOVERY_FILE_DEST_SIZE=10G
*.DB_RECOVERY_FILE_DEST='C:\oraclexe\app\oracle\fast_recovery_area'
*.diagnostic_dest='C:\oraclexe\app\oracle\.'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=XEXDB)'
*.job_queue_processes=4
*.memory_target=1024M
*.open_cursors=300
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=20
*.shared_servers=4
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
-----End of pfile.ora ----------------------

SQL> startup pfile=C:\Users\Bext\Documents\JPAtutorial\pfile.ora;
ORACLE instance started.

Total System Global Area 1068937216 bytes
Fixed Size                  2260048 bytes
Variable Size             633340848 bytes
Database Buffers          427819008 bytes
Redo Buffers                5517312 bytes
Database mounted.
Database opened.
SQL>

SQL> create spfile from pfile='C:\Users\Bext\Documents\JPAtutorial\pfile.ora';

File created.

*** SQL utiles
SQL> select username from dba_users;
SQL> select tablespace_name from dba_tablespaces;
SQL> create tablespace develop_tabspace
  2  datafile 'develop_tabspace.dat'
  3  size 10M autoextend on;
SQL> drop tablespace develop_tablespace_temp;
SQL> select file_name, tablespace_name from dba_temp_files;
SQL> select tablespace_name from V$temp_space_header;
SQL> alter database tempfile 'C:\oraclexe\app\oracle\product\11.2.0\server\database\develop_tabspace_temp.dat' drop including datafiles;


Arrancar servicios oracle rápido

   start -> run -> services.msc
 
seleccionar el servicio Oracle y arrancarlos.




miércoles, 17 de mayo de 2017

Configurar Power Designer

  Cuando se intenta hacer un reverse ingeeniering via JDBC. se reporta "Could not initialize JavaVM!"

Resuelto:

Source:
http://sybase.public.powerdesigner.general.narkive.com/xsK2vFdO/error-could-not-initialize-javavm

Extract:
Recently I had problem with running database reverse engineering via
JDBC. PowerDesigner reported "Could not initialize JavaVM!" problem.
OS: Windows7 64bit
PowerDesigner version: 12.5, 15.3

Solution: It appears that PowerDesigner requires 32bit JRE!!!
1) In menu Tools > General Options > Variables set variable JAVA to location of your java.exe (e.g. c:\java\jre6\bin\java.exe)
2) Add path to file jvm.dll to you PATH system variable (e.g. c:\java
\jre6\bin\client)
3) Create system variable CLASSPATH (if not exists) and add JDBC driver
for your database with full path into it (e.g. c:\drivers\jdbc\ojdbc14.jar)

En mi caso:










Path=C:\oraclexe\app\oracle\product\11.2.0\server\bin;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Brackets\command;C:\Program Files\apache-maven-3.5.0\bin;C:\Program Files\Java\jdk1.7.0_79\bin;C:\Program Files\MySQL\MySQL Utilities 1.6\;C:\Program Files\Git\cmd;C:\Program Files\Heroku\bin;C:\Program Files\Docker Toolbox
CLASSPATH=C:\Program Files (x86)\MySQL\Connector.J 5.1\mysql-connector-java-5.1.41-bin.jar

y Listo!

miércoles, 10 de mayo de 2017

Configurar jdbcConnectionPool MySQL Glassfish

En una version anterior a glassfish 4.1.1 no me permitia modificar/configurar conection pool de jdbc, en su administrador web del glassfish, simplemente tronaba, se soluciona haciendo el trabajo desde linea de comandos en el asadmin de glassfish


Glassfish Server
glassfish manual and javaee7tutorial manual

== start server ===
asadmin start-domain --verbose

glassfish server port number: default 8080
administrator server's port number: default 4848
administrator user name and password: username admin no password

output also go to the server log:
domain-dir/logs/server.log

== stop server ==
asadmin stop-domain domain1

== start admin console ==
http://localhost:4848/.

== start/stop the java DB Server ==
asadmin start-database
asadmin stop-database

http://www.oracle.com/technetwork/java/javadb/overview/index.html.

== glassfish Create resources administratively ===
asadmin add-resources glassfish-resources.xml




Configuracion de Recursos DataSource, ConnectionPoolDataSource

asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource --restype javax.sql.DataSource --property User=[db_username]:Port=3306:Password=[db_password]:Url="jdbc:mysql://[localhost or ip]:3306/[db_name]" [pool_name]

example

./asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource --restype javax.sql.DataSource --property User=admin:Port=3306:Password=admin:Url="jdbc:mysql://127.0.0.1:3306/\test" test_pool

on practice

./asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource --restype javax.sql.DataSource --property User=root:Port=3306:Password=wsp:Url="jdbc:mysql://localhost:3306/\wsp" test_pool

asadmin> create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource --restype javax.sql.DataSource
Enter the value for the jdbc_connection_pool_id operand> test_pool
JDBC connection pool test_pool created successfully.

asadmin> create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource --restype javax.sql.DataSource --property Url="jdbc:mysql://localhost:3306/wsp"
Enter the value for the jdbc_connection_pool_id operand> JPAconnPoolMysql
remote failure: Invalid property syntax, missing property value: mysql
Invalid property syntax, missing property value: mysql

asadmin> create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource --restype javax.sql.DataSource --property Url="jdbc\:mysql\://localhost\:3306/wsp"


EXITO

asadmin> create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource --restype javax.sql.ConnectionPoolDataSource --property Url="jdbc\:mysql\://localhost\:3306/wsp" JPAconnectionPool
Command create-jdbc-connection-pool executed successfully.

Despues desde el Glassfish manager se modifica el ConnectionPool Resource se agregan properties User=root y Password=algoalgo

asadmin> create-jdbc-resource --connectionpoolid JPAconnectionPool jdbc/jpa
JDBC resource jdbc/jpa created successfully.
Command create-jdbc-resource executed successfully.
asadmin>

** Creacion para JPA Cases **
asadmin> create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource --restype javax.sql.ConnectionPoolDataSource --property Url="jdbc\:mysql\://localhost\:3306/JPACases" JPAconnPoolCases

asadmin> create-jdbc-resource --connectionpoolid JPAconnPoolCases jdbc/jpaCases

=================================================================Installing Maven for Netbeans build samples

MAVEN_HOME=C:\Program Files\apache-maven-3.5.0
C:\ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Brackets\command;%MAVEN_HOME%\bin;%JAVA_HOME%\bin;C:\Program Files\MySQL\MySQL Utilities 1.6\

martes, 2 de mayo de 2017

Java Persistence API (JPA) con EclipseLink y Eclipse IDE

   Abordamos una análisis de como implementa JPA la librería EclipseLink open source, como desdobla las anotaciones en java en sus entidades hacia una base de datos en su ORM (Object- Relational Model), se hace en el IDE Eclipse ya que es natural su integración.

http://www.eclipse.org/eclipselink/

jueves, 27 de abril de 2017

Empezando Java Persistence API (JPA)

   Java EE integra una librería que ayuda al programador en java, en el manejo de datos que deben ir a una base de datos, pero existe un detalle en este dilema, por un lado tradicionalmente los datos se reflejan en un diseño en una Base de datos por medio de un diagrama Entidad-Relación, y por otro lado, desde el punto de vista de programación java, estos datos estan contenidos y representados en clases, y las classes no siguen las mismas reglas y/o formato que las Entidades en la Base de datos, entonces hablamos de un tradicional problema de impedancia en la representación de los datos, ya que por un lado, en java, las classes tienen capacidades funcionales de manejo dinámico de comportamiento de las clases, que no tiene mucho enfasis en los datos que contiene la clase y que se desean persistir o sea guardar en la base de datos, y por el lado de la base de datos, las entidades que representan los datos almacenados. Asi que por lo general se debe de hacer una interfaz entre las clases de java y las entidades de la base de datos, esto se hace haciendo una capa de interfaz con programación java entre las clases java y las tablas de la base de datos, implementando esto con alguna herramienta que hable java-base da datos, como puede ser JDBC. esto implica tambien programar una serie de utilidades que controlen concurrencia, bloqueo... de los datos. Todo esto se puede eliminar haciendo uso de la librería de java JPA (Java Persistence API) que contempla muchas de las operaciones requeridad en el proceso de guardar, recuperar, actualizar datos de la base de datos. Estas operaciones no son pocas, ni sencillas de controlar, sobre todo cuando se tienen entidades relacionadas a varios niveles, ya que para esto existen varias estrategías de control con sus pros y contras, que se dejan para otro apartado.
  Para empezar se suguiere asimilar los conceptos de JPA que se describen sintetizados en el manual de especificación de Java EE que se puede encontrar en el portal de oracle. aquí se tomas 20 páginas para describirlo.
  Posteriormente un documento que amplía estos conceptos es su propia especificación JSR 338 (java specification request) tambien del portal de oracle se obtiene. este documento es de 570 páginas.

Para más información
Java Persistence 2.1 API specification:
http://jcp.org/en/jsr/detail?id=338
■ EclipseLink, the Java Persistence API implementation in GlassFish Server:
http://www.eclipse.org/eclipselink/jpa.php
■ EclipseLink team blog:
http://eclipselink.blogspot.com/
■ EclipseLink wiki documentation:
http://wiki.eclipse.org/EclipseLink

  Adicionalmente a estas especificaciones están las implementaciones de esta especificacion, estas son el software o librerías que se pueden descargar, entre estas estan ElicpseLink, TopLink, Hibernate, Apache OpenJPA, etc. entre ellos existe una permanente competencia por agregar servicios de persistencia que van más alla de la especificacion estandar JSR 338, como son MOXy, EIS, SDO, DBWS etc y algunas variantes de conceptos. Por ejemplo Hibernate ofrece varios servicios y formas adicionales, PERO la escencia de la persistencia de datos esta en la especificación, esto hace que sea independiente a cambios en tecnología o implementaciones que hagan caducar estas implementaciones adicionales y dejar fuera a la aplicación desarrollada.


domingo, 16 de abril de 2017

Laboratorio JPA 2.0 EclipseLink Employee model with Oracle DB



Este laboratorio ejemplo se obtiene del link  http://wiki.eclipse.org/EclipseLink/Examples/JPA/2.0/Employee

Se ejecuta en Netbeans, y se hace una configuración previa en la base de datos oracle, creando un usuario develop y sus tablespace etc...

Se hacen ajustes en pesistence.xml y se crea un a conneción a la base de datos oracle


En este ejemplo de eclipselink en el archivo persistence.xml que configura la persistence unit, se observa la inclusión a este archivo de las entity classes que se reflejaran posteriormente en tablas en la base de datos.
    El projecto contiene tres archivos java transactions, queries, populate la que manda a llamar el projecto es transactions que crea la entityManager, y hace transacciones usando persist, merge, con variante pesimistlocking y una actualización.
  En queries.java se llama a populate que pobla las tablas que se crearon con datos con lógica según la estructura y despues hace varios queries como ejemplo haciendo uso de CriteriaBuilder, QueryByExample.

El projecto en Netbeans se ve así


La construcción de las tablas en base de datos quedan así


La ejecución no da:
run:
[EL Config]: metadata: The access type for the persistent class [class model.Employee] is set to [FIELD].
[EL Config]: metadata: The target entity (reference) class for the one to one mapping element [field address] is being defaulted to: class model.Address.
[EL Config]: metadata: The target entity (reference) class for the many to many mapping element [field projects] is being defaulted to: class model.Project.
[EL Config]: metadata: The target entity (reference) class for the many to one mapping element [field manager] is being defaulted to: class model.Employee.
[EL Config]: metadata: The target entity (reference) class for the many to one mapping element [field jobTitle] is being defaulted to: class model.JobTitle.
[EL Config]: metadata: The target entity (reference) class for the one to many mapping element [field managedEmployees] is being defaulted to: class model.Employee.
[EL Config]: metadata: The target entity (reference) class for the one to many mapping element [field phoneNumbers] is being defaulted to: class model.PhoneNumber.
[EL Config]: metadata: The target entity (reference) class for the one to many mapping element [field degrees] is being defaulted to: class model.Degree.
[EL Config]: metadata: The target class (reference) class for the element collection mapping element [field responsibilities] is being defaulted to: class java.lang.String.
[EL Config]: metadata: The target class (reference) class for the element collection mapping element [field emailAddresses] is being defaulted to: class model.EmailAddress.
[EL Config]: metadata: The access type for the persistent class [class model.Degree] is set to [FIELD].
[EL Config]: metadata: The access type for the persistent class [class model.Project] is set to [FIELD].
[EL Config]: metadata: The target entity (reference) class for the many to one mapping element [field teamLeader] is being defaulted to: class model.Employee.
[EL Config]: metadata: The access type for the persistent class [class model.SmallProject] is set to [FIELD].
[EL Config]: metadata: The access type for the persistent class [class model.Address] is set to [FIELD].
[EL Config]: metadata: The access type for the persistent class [class model.PhoneNumber] is set to [FIELD].
[EL Config]: metadata: The element [field owner] is being defaulted to a one to one mapping.
[EL Config]: metadata: The target entity (reference) class for the many to one mapping element [field owner] is being defaulted to: class model.Employee.
[EL Config]: metadata: The access type for the persistent class [class model.JobTitle] is set to [FIELD].
[EL Config]: metadata: The access type for the persistent class [class model.LargeProject] is set to [FIELD].
[EL Config]: metadata: The access type for the persistent class [class model.EmploymentPeriod] is set to [FIELD].
[EL Config]: metadata: The access type for the persistent class [class model.EmailAddress] is set to [FIELD].
[EL Config]: metadata: The alias name for the entity class [class model.Employee] is being defaulted to: Employee.
[EL Config]: metadata: The table name for entity [class model.Employee] is being defaulted to: EMPLOYEE.
[EL Config]: metadata: The column name for element [endDate] is being defaulted to: ENDDATE.
[EL Config]: metadata: The column name for element [startDate] is being defaulted to: STARTDATE.
[EL Config]: metadata: The column name for element [salary] is being defaulted to: SALARY.
[EL Config]: metadata: The column name for element [version] is being defaulted to: VERSION.
[EL Config]: metadata: The secondary table primary key column name for element [class model.Employee] is being defaulted to: EMP_ID.
[EL Config]: metadata: The secondary table foreign key column name for element [model.Employee] is being defaulted to: EMP_ID.
[EL Config]: metadata: The alias name for the entity class [class model.Degree] is being defaulted to: Degree.
[EL Config]: metadata: The table name for entity [class model.Degree] is being defaulted to: DEGREE.
[EL Config]: metadata: The column name for element [name] is being defaulted to: NAME.
[EL Config]: metadata: The alias name for the entity class [class model.SmallProject] is being defaulted to: SmallProject.
[EL Config]: metadata: The alias name for the entity class [class model.Project] is being defaulted to: Project.
[EL Config]: metadata: The table name for entity [class model.Project] is being defaulted to: PROJECT.
[EL Config]: metadata: The column name for element [version] is being defaulted to: VERSION.
[EL Config]: metadata: The primary key column name for the inheritance class [class model.SmallProject] is being defaulted to: PROJ_ID.
[EL Config]: metadata: The foreign key column name for the inheritance class [model.SmallProject] is being defaulted to: PROJ_ID.
[EL Config]: metadata: The alias name for the entity class [class model.Address] is being defaulted to: Address.
[EL Config]: metadata: The table name for entity [class model.Address] is being defaulted to: ADDRESS.
[EL Config]: metadata: The column name for element [country] is being defaulted to: COUNTRY.
[EL Config]: metadata: The column name for element [province] is being defaulted to: PROVINCE.
[EL Config]: metadata: The column name for element [city] is being defaulted to: CITY.
[EL Config]: metadata: The column name for element [street] is being defaulted to: STREET.
[EL Config]: metadata: The alias name for the entity class [class model.PhoneNumber] is being defaulted to: PhoneNumber.
[EL Config]: metadata: The column name for element [type] is being defaulted to: TYPE.
[EL Config]: metadata: The alias name for the entity class [class model.JobTitle] is being defaulted to: JobTitle.
[EL Config]: metadata: The table name for entity [class model.JobTitle] is being defaulted to: JOBTITLE.
[EL Config]: metadata: The column name for element [title] is being defaulted to: TITLE.
[EL Config]: metadata: The alias name for the entity class [class model.LargeProject] is being defaulted to: LargeProject.
[EL Config]: metadata: The primary key column name for the inheritance class [class model.LargeProject] is being defaulted to: PROJ_ID.
[EL Config]: metadata: The foreign key column name for the inheritance class [model.LargeProject] is being defaulted to: PROJ_ID.
[EL Config]: metadata: The column name for element [milestone] is being defaulted to: MILESTONE.
[EL Config]: metadata: The column name for element [budget] is being defaulted to: BUDGET.
[EL Config]: metadata: The primary key column name for the mapping element [field owner] is being defaulted to: EMP_ID.
[EL Config]: metadata: The primary key column name for the mapping element [field responsibilities] is being defaulted to: EMP_ID.
[EL Config]: metadata: The primary key column name for the mapping element [field address] is being defaulted to: ADDRESS_ID.
[EL Config]: metadata: The source primary key column name for the many to many mapping [field projects] is being defaulted to: EMP_ID.
[EL Config]: metadata: The target primary key column name for the many to many mapping [field projects] is being defaulted to: PROJ_ID.
[EL Config]: metadata: The primary key column name for the mapping element [field manager] is being defaulted to: EMP_ID.
[EL Config]: metadata: The source primary key column name for the many to many mapping [field jobTitle] is being defaulted to: EMP_ID.
[EL Config]: metadata: The target primary key column name for the many to many mapping [field jobTitle] is being defaulted to: JOB_ID.
[EL Config]: metadata: The primary key column name for the mapping element [field degrees] is being defaulted to: EMP_ID.
[EL Config]: metadata: The primary key column name for the mapping element [field teamLeader] is being defaulted to: EMP_ID.
[EL Config]: metadata: The primary key column name for the mapping element [field emailAddresses] is being defaulted to: EMP_ID.
Creating new employee using persist.
[EL Info]: EclipseLink, version: Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd
[EL Fine]: connection: Detected database platform: org.eclipse.persistence.platform.database.oracle.Oracle11Platform
[EL Config]: connection: Connection(95553286)--connecting(DatabaseLogin(
    platform=>Oracle11Platform
    user name=> "develop"
    datasource URL=> "jdbc:oracle:thin:@localhost:1521"
))
[EL Config]: connection: Connection(380556447)--Connected: jdbc:oracle:thin:@localhost:1521
    User: DEVELOP
    Database: Oracle  Version: Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
    Driver: Oracle JDBC driver  Version: 11.2.0.2.0
[EL Warning]: metadata: Reverting the lazy setting on the OneToOne or ManyToOne attribute [address] for the entity class [class model.Employee] since weaving was not enabled or did not occur.
[EL Warning]: metadata: Reverting the lazy setting on the OneToOne or ManyToOne attribute [manager] for the entity class [class model.Employee] since weaving was not enabled or did not occur.
[EL Warning]: metadata: Reverting the lazy setting on the OneToOne or ManyToOne attribute [jobTitle] for the entity class [class model.Employee] since weaving was not enabled or did not occur.
[EL Warning]: metadata: Reverting the lazy setting on the OneToOne or ManyToOne attribute [owner] for the entity class [class model.PhoneNumber] since weaving was not enabled or did not occur.
[EL Warning]: metadata: Reverting the lazy setting on the OneToOne or ManyToOne attribute [teamLeader] for the entity class [class model.Project] since weaving was not enabled or did not occur.
[EL Info]: connection: file:/C:/Users/Bext/Documents/NetBeansProjects/jpa_employee_annotations/build/classes/_employee login successful
[EL Fine]: sql: Connection(380556447)--ALTER TABLE PROJECT DROP CONSTRAINT FK_PROJECT_LEADER_ID
[EL Fine]: sql: Connection(380556447)--ALTER TABLE PHONE DROP CONSTRAINT FK_PHONE_EMP_ID
[EL Fine]: sql: Connection(380556447)--ALTER TABLE LPROJECT DROP CONSTRAINT FK_LPROJECT_PROJ_ID
[EL Fine]: sql: Connection(380556447)--ALTER TABLE EMPLOYEE DROP CONSTRAINT FK_EMPLOYEE_MANAGER_ID
[EL Fine]: sql: Connection(380556447)--ALTER TABLE EMPLOYEE DROP CONSTRAINT FK_EMPLOYEE_ADDR_ID
[EL Fine]: sql: Connection(380556447)--ALTER TABLE SALARY DROP CONSTRAINT FK_SALARY_EMP_ID
[EL Fine]: sql: Connection(380556447)--ALTER TABLE DEGREE DROP CONSTRAINT FK_DEGREE_EMP_ID
[EL Fine]: sql: Connection(380556447)--ALTER TABLE EMP_JOB DROP CONSTRAINT FK_EMP_JOB_EMP_ID
[EL Fine]: sql: Connection(380556447)--ALTER TABLE EMP_JOB DROP CONSTRAINT FK_EMP_JOB_TITLE_ID
[EL Fine]: sql: Connection(380556447)--ALTER TABLE EMAIL DROP CONSTRAINT FK_EMAIL_EMP_ID
[EL Fine]: sql: Connection(380556447)--ALTER TABLE RESPONS DROP CONSTRAINT FK_RESPONS_EMP_ID
[EL Fine]: sql: Connection(380556447)--ALTER TABLE PROJ_EMP DROP CONSTRAINT FK_PROJ_EMP_EMP_ID
[EL Fine]: sql: Connection(380556447)--ALTER TABLE PROJ_EMP DROP CONSTRAINT FK_PROJ_EMP_PROJ_ID
[EL Fine]: sql: Connection(380556447)--DROP TABLE PROJECT CASCADE CONSTRAINTS
[EL Fine]: sql: Connection(380556447)--DROP TABLE PHONE CASCADE CONSTRAINTS
[EL Fine]: sql: Connection(380556447)--DROP TABLE LPROJECT CASCADE CONSTRAINTS
[EL Fine]: sql: Connection(380556447)--DROP TABLE EMPLOYEE CASCADE CONSTRAINTS
[EL Fine]: sql: Connection(380556447)--DROP TABLE SALARY CASCADE CONSTRAINTS
[EL Fine]: sql: Connection(380556447)--DROP TABLE ADDRESS CASCADE CONSTRAINTS
[EL Fine]: sql: Connection(380556447)--DROP TABLE JOBTITLE CASCADE CONSTRAINTS
[EL Fine]: sql: Connection(380556447)--DROP TABLE DEGREE CASCADE CONSTRAINTS
[EL Fine]: sql: Connection(380556447)--DROP TABLE EMP_JOB CASCADE CONSTRAINTS
[EL Fine]: sql: Connection(380556447)--DROP TABLE EMAIL CASCADE CONSTRAINTS
[EL Fine]: sql: Connection(380556447)--DROP TABLE RESPONS CASCADE CONSTRAINTS
[EL Fine]: sql: Connection(380556447)--DROP TABLE PROJ_EMP CASCADE CONSTRAINTS
[EL Fine]: sql: Connection(380556447)--CREATE TABLE PROJECT (PROJ_ID NUMBER(10) NOT NULL, PROJ_TYPE VARCHAR2(31) NULL, DESCRIP VARCHAR2(255) NULL, PROJ_NAME VARCHAR2(255) NULL, VERSION NUMBER(19) NULL, LEADER_ID NUMBER(19) NULL, PRIMARY KEY (PROJ_ID))
[EL Fine]: sql: Connection(380556447)--CREATE TABLE PHONE (TYPE VARCHAR2(255) NOT NULL, AREA_CODE VARCHAR2(255) NULL, P_NUMBER VARCHAR2(255) NULL, EMP_ID NUMBER(19) NOT NULL, PRIMARY KEY (TYPE, EMP_ID))
[EL Fine]: sql: Connection(380556447)--CREATE TABLE LPROJECT (PROJ_ID NUMBER(10) NOT NULL, BUDGET NUMBER(19,4) NULL, MILESTONE TIMESTAMP NULL, PRIMARY KEY (PROJ_ID))
[EL Fine]: sql: Connection(380556447)--CREATE TABLE EMPLOYEE (EMP_ID NUMBER(19) NOT NULL, F_NAME VARCHAR2(255) NULL, GENDER VARCHAR2(255) NULL, L_NAME VARCHAR2(255) NULL, VERSION NUMBER(19) NULL, END_DATE DATE NULL, START_DATE DATE NULL, MANAGER_ID NUMBER(19) NULL, ADDR_ID NUMBER(19) NULL, PRIMARY KEY (EMP_ID))
[EL Fine]: sql: Connection(380556447)--CREATE TABLE SALARY (EMP_ID NUMBER(19) NOT NULL, SALARY NUMBER(19,4) NULL, PRIMARY KEY (EMP_ID))
[EL Fine]: sql: Connection(380556447)--CREATE TABLE ADDRESS (ADDRESS_ID NUMBER(19) NOT NULL, CITY VARCHAR2(255) NULL, COUNTRY VARCHAR2(255) NULL, P_CODE VARCHAR2(255) NULL, PROVINCE VARCHAR2(255) NULL, STREET VARCHAR2(255) NULL, PRIMARY KEY (ADDRESS_ID))
[EL Fine]: sql: Connection(380556447)--CREATE TABLE JOBTITLE (JOB_ID NUMBER(19) NOT NULL, TITLE VARCHAR2(255) NULL, PRIMARY KEY (JOB_ID))
[EL Fine]: sql: Connection(380556447)--CREATE TABLE DEGREE (DEGREE_ID NUMBER(19) NOT NULL, NAME VARCHAR2(255) NULL, EMP_ID NUMBER(19) NULL, PRIMARY KEY (DEGREE_ID))
[EL Fine]: sql: Connection(380556447)--CREATE TABLE EMP_JOB (EMP_ID NUMBER(19) NOT NULL, TITLE_ID NUMBER(19) NOT NULL, PRIMARY KEY (EMP_ID, TITLE_ID))
[EL Fine]: sql: Connection(380556447)--CREATE TABLE EMAIL (EMAIL_TYPE VARCHAR2(255) NULL, EMAIL_ADDRESS VARCHAR2(255) NULL, EMP_ID NUMBER(19) NULL)
[EL Fine]: sql: Connection(380556447)--CREATE TABLE RESPONS (EMP_ID NUMBER(19) NULL, RESPONSIBILITY VARCHAR2(255) NULL, PRIORITY NUMBER(10) NULL)
[EL Fine]: sql: Connection(380556447)--CREATE TABLE PROJ_EMP (EMP_ID NUMBER(19) NOT NULL, PROJ_ID NUMBER(10) NOT NULL, PRIMARY KEY (EMP_ID, PROJ_ID))
[EL Fine]: sql: Connection(380556447)--ALTER TABLE PROJECT ADD CONSTRAINT FK_PROJECT_LEADER_ID FOREIGN KEY (LEADER_ID) REFERENCES EMPLOYEE (EMP_ID)
[EL Fine]: sql: Connection(380556447)--ALTER TABLE PHONE ADD CONSTRAINT FK_PHONE_EMP_ID FOREIGN KEY (EMP_ID) REFERENCES EMPLOYEE (EMP_ID)
[EL Fine]: sql: Connection(380556447)--ALTER TABLE LPROJECT ADD CONSTRAINT FK_LPROJECT_PROJ_ID FOREIGN KEY (PROJ_ID) REFERENCES PROJECT (PROJ_ID)
[EL Fine]: sql: Connection(380556447)--ALTER TABLE EMPLOYEE ADD CONSTRAINT FK_EMPLOYEE_MANAGER_ID FOREIGN KEY (MANAGER_ID) REFERENCES EMPLOYEE (EMP_ID)
[EL Fine]: sql: Connection(380556447)--ALTER TABLE EMPLOYEE ADD CONSTRAINT FK_EMPLOYEE_ADDR_ID FOREIGN KEY (ADDR_ID) REFERENCES ADDRESS (ADDRESS_ID)
[EL Fine]: sql: Connection(380556447)--ALTER TABLE SALARY ADD CONSTRAINT FK_SALARY_EMP_ID FOREIGN KEY (EMP_ID) REFERENCES EMPLOYEE (EMP_ID)
[EL Fine]: sql: Connection(380556447)--ALTER TABLE DEGREE ADD CONSTRAINT FK_DEGREE_EMP_ID FOREIGN KEY (EMP_ID) REFERENCES EMPLOYEE (EMP_ID)
[EL Fine]: sql: Connection(380556447)--ALTER TABLE EMP_JOB ADD CONSTRAINT FK_EMP_JOB_EMP_ID FOREIGN KEY (EMP_ID) REFERENCES EMPLOYEE (EMP_ID)
[EL Fine]: sql: Connection(380556447)--ALTER TABLE EMP_JOB ADD CONSTRAINT FK_EMP_JOB_TITLE_ID FOREIGN KEY (TITLE_ID) REFERENCES JOBTITLE (JOB_ID)
[EL Fine]: sql: Connection(380556447)--ALTER TABLE EMAIL ADD CONSTRAINT FK_EMAIL_EMP_ID FOREIGN KEY (EMP_ID) REFERENCES EMPLOYEE (EMP_ID)
[EL Fine]: sql: Connection(380556447)--ALTER TABLE RESPONS ADD CONSTRAINT FK_RESPONS_EMP_ID FOREIGN KEY (EMP_ID) REFERENCES EMPLOYEE (EMP_ID)
[EL Fine]: sql: Connection(380556447)--ALTER TABLE PROJ_EMP ADD CONSTRAINT FK_PROJ_EMP_EMP_ID FOREIGN KEY (EMP_ID) REFERENCES EMPLOYEE (EMP_ID)
[EL Fine]: sql: Connection(380556447)--ALTER TABLE PROJ_EMP ADD CONSTRAINT FK_PROJ_EMP_PROJ_ID FOREIGN KEY (PROJ_ID) REFERENCES PROJECT (PROJ_ID)
[EL Fine]: sql: Connection(380556447)--DROP SEQUENCE SEQ_GEN_SEQUENCE
[EL Fine]: sql: Connection(380556447)--SELECT SEQ_GEN_SEQUENCE.NEXTVAL FROM DUAL
[EL Fine]: sql: SELECT 1 FROM DUAL
[EL Warning]: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: ORA-02289: sequence does not exist

Error Code: 2289
Call: SELECT SEQ_GEN_SEQUENCE.NEXTVAL FROM DUAL
Query: ValueReadQuery(sql="SELECT SEQ_GEN_SEQUENCE.NEXTVAL FROM DUAL")
[EL Fine]: sql: Connection(380556447)--CREATE SEQUENCE SEQ_GEN_SEQUENCE INCREMENT BY 50 START WITH 50
[EL Fine]: sql: Connection(380556447)--SELECT SEQ_GEN_SEQUENCE.NEXTVAL FROM DUAL
[EL Fine]: sql: Connection(380556447)--INSERT INTO ADDRESS (ADDRESS_ID, CITY, COUNTRY, P_CODE, PROVINCE, STREET) VALUES (?, ?, ?, ?, ?, ?)
    bind => [2, null, null, null, null, null]
[EL Fine]: sql: Connection(380556447)--INSERT INTO EMPLOYEE (EMP_ID, F_NAME, GENDER, L_NAME, VERSION, END_DATE, START_DATE, MANAGER_ID, ADDR_ID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
    bind => [1, Sample, Male, Employee, 1, null, null, null, 2]
[EL Fine]: sql: Connection(380556447)--INSERT INTO PHONE (TYPE, AREA_CODE, P_NUMBER, EMP_ID) VALUES (?, ?, ?, ?)
    bind => [Mobile, 613, 555-1212, 1]
[EL Fine]: sql: Connection(380556447)--INSERT INTO SALARY (SALARY, EMP_ID) VALUES (?, ?)
    bind => [123456.0, 1]
Creating new employee using merge.
[EL Fine]: sql: Connection(380556447)--SELECT TYPE, AREA_CODE, P_NUMBER, EMP_ID FROM PHONE WHERE ((TYPE = ?) AND (EMP_ID = ?))
    bind => [Mobile, 0]
[EL Fine]: sql: Connection(380556447)--INSERT INTO ADDRESS (ADDRESS_ID, CITY, COUNTRY, P_CODE, PROVINCE, STREET) VALUES (?, ?, ?, ?, ?, ?)
    bind => [4, null, null, null, null, null]
[EL Fine]: sql: Connection(380556447)--INSERT INTO EMPLOYEE (EMP_ID, F_NAME, GENDER, L_NAME, VERSION, END_DATE, START_DATE, MANAGER_ID, ADDR_ID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
    bind => [3, Sample, Male, Employee, 1, null, null, null, 4]
[EL Fine]: sql: Connection(380556447)--INSERT INTO PHONE (TYPE, AREA_CODE, P_NUMBER, EMP_ID) VALUES (?, ?, ?, ?)
    bind => [Mobile, 613, 555-1212, 3]
[EL Fine]: sql: Connection(380556447)--INSERT INTO SALARY (SALARY, EMP_ID) VALUES (?, ?)
    bind => [123456.0, 3]
Using pessimistic locking on employee.
[EL Fine]: sql: Connection(380556447)--SELECT t0.EMP_ID FROM EMPLOYEE t0, SALARY t1 WHERE (t1.EMP_ID = t0.EMP_ID)
[EL Fine]: sql: Connection(380556447)--SELECT t0.EMP_ID, t1.EMP_ID, t0.F_NAME, t0.GENDER, t0.L_NAME, t1.SALARY, t0.VERSION, t0.END_DATE, t0.START_DATE, t0.MANAGER_ID, t0.ADDR_ID FROM EMPLOYEE t0, SALARY t1 WHERE ((t0.EMP_ID = ?) AND (t1.EMP_ID = t0.EMP_ID)) FOR UPDATE
    bind => [1]
[EL Fine]: sql: Connection(380556447)--SELECT t1.JOB_ID, t1.TITLE FROM EMP_JOB t0, JOBTITLE t1 WHERE ((t0.EMP_ID = ?) AND (t1.JOB_ID = t0.TITLE_ID))
    bind => [1]
[EL Fine]: sql: Connection(380556447)--SELECT EMAIL_ADDRESS, EMAIL_TYPE, EMP_ID FROM EMAIL WHERE (EMP_ID = ?)
    bind => [1]
[EL Fine]: sql: Connection(380556447)--SELECT t0.RESPONSIBILITY, t0.PRIORITY FROM RESPONS t0 WHERE (t0.EMP_ID = ?)
    bind => [1]
[EL Fine]: sql: Connection(380556447)--SELECT DISTINCT t1.PROJ_TYPE FROM PROJ_EMP t0, PROJECT t1 WHERE ((t0.EMP_ID = ?) AND (t1.PROJ_ID = t0.PROJ_ID))
    bind => [1]
[EL Fine]: sql: Connection(380556447)--SELECT t0.EMP_ID, t1.EMP_ID, t0.F_NAME, t0.GENDER, t0.L_NAME, t1.SALARY, t0.VERSION, t0.END_DATE, t0.START_DATE, t0.MANAGER_ID, t0.ADDR_ID FROM EMPLOYEE t0, SALARY t1 WHERE ((t0.MANAGER_ID = ?) AND (t1.EMP_ID = t0.EMP_ID))
    bind => [1]
[EL Fine]: sql: Connection(380556447)--SELECT TYPE, AREA_CODE, P_NUMBER, EMP_ID FROM PHONE WHERE (EMP_ID = ?)
    bind => [1]
[EL Fine]: sql: Connection(380556447)--SELECT DEGREE_ID, NAME FROM DEGREE WHERE (EMP_ID = ?)
    bind => [1]
[EL Fine]: sql: Connection(380556447)--UPDATE EMPLOYEE SET VERSION = ? WHERE ((EMP_ID = ?) AND (VERSION = ?))
    bind => [2, 1, 1]
[EL Fine]: sql: Connection(380556447)--UPDATE SALARY SET SALARY = ? WHERE (EMP_ID = ?)
    bind => [123455.0, 1]
Querying employee and its address' city and updating the employee's salary.
[EL Fine]: sql: Connection(380556447)--SELECT t0.EMP_ID, t1.EMP_ID, t0.F_NAME, t0.GENDER, t0.L_NAME, t1.SALARY, t0.VERSION, t0.END_DATE, t0.START_DATE, t0.MANAGER_ID, t0.ADDR_ID, t2.CITY FROM EMPLOYEE t0, ADDRESS t2, SALARY t1 WHERE ((t1.EMP_ID = t0.EMP_ID) AND (t2.ADDRESS_ID = t0.ADDR_ID))
[EL Fine]: sql: Connection(380556447)--UPDATE EMPLOYEE SET VERSION = ? WHERE ((EMP_ID = ?) AND (VERSION = ?))
    bind => [3, 1, 2]
[EL Fine]: sql: Connection(380556447)--UPDATE SALARY SET SALARY = ? WHERE (EMP_ID = ?)
    bind => [123456.0, 1]
[EL Config]: connection: Connection(380556447)--disconnect
[EL Info]: connection: file:/C:/Users/Bext/Documents/NetBeansProjects/jpa_employee_annotations/build/classes/_employee logout successful
[EL Config]: connection: Connection(95553286)--disconnect
BUILD SUCCESSFUL (total time: 9 seconds)

Cabe mensionar que el archivo pesistence.xml de configuración del persistence unit tiene una propiedad que borra y crea las tablas a partir del código java que describe las entidades
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
así que si se vuelve a correr las borrará y creará de nuevo.

las tablas generadas vistas desde ide Netbeans :