@ Override public int write2DB ( ) throws VMException { try { VmIdJpaController controller = new VmIdJpaController ( getEntityManagerFactory ( ) ) ; VmId vmId ; if ( getId ( ) == null ) { vmId = new VmId ( ) ; update ( vmId , this ) ; controller . create ( vmId ) ; setId ( vmId . getId ( ) ) ; } else { vmId = getEntity ( ) ; update ( vmId , this ) ; controller . edit ( vmId ) ; } update ( ) ; return getId ( ) ; } catch ( Exception ex ) { LOG . log ( Level . SEVERE , null , ex ) ; throw new VMException ( ex ) ; } }
write to db