HHH-10354 - Rename 'field access' to 'extended enhancement'
This commit is contained in:
parent
20ebd8f5ca
commit
6828f5ee9b
|
@ -69,8 +69,8 @@ public class PersistentAttributesEnhancer extends Enhancer {
|
||||||
enhanceAttributesAccess( managedCtClass, attrDescriptorMap );
|
enhanceAttributesAccess( managedCtClass, attrDescriptorMap );
|
||||||
|
|
||||||
// same thing for direct access to fields of other entities
|
// same thing for direct access to fields of other entities
|
||||||
if ( this.enhancementContext.doFieldAccessEnhancement( managedCtClass ) ) {
|
if ( this.enhancementContext.doExtendedEnhancement( managedCtClass ) ) {
|
||||||
enhanceFieldAccess( managedCtClass );
|
extendedEnhancement( managedCtClass );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,7 +390,7 @@ public class PersistentAttributesEnhancer extends Enhancer {
|
||||||
" if ($1 != null && %s) {%n" +
|
" if ($1 != null && %s) {%n" +
|
||||||
" Object[] array = $1.toArray();%n" +
|
" Object[] array = $1.toArray();%n" +
|
||||||
" for (int i = 0; i < array.length; i++) {%n" +
|
" for (int i = 0; i < array.length; i++) {%n" +
|
||||||
" %s target = (%<s) array[i];%n" +
|
" %s target = (%s) array[i];%n" +
|
||||||
" if (%s) {%n" +
|
" if (%s) {%n" +
|
||||||
" java.util.Collection c = target.%s();%n" +
|
" java.util.Collection c = target.%s();%n" +
|
||||||
" if (c != this && c != null) { c.add(this); }%n" +
|
" if (c != this && c != null) { c.add(this); }%n" +
|
||||||
|
@ -399,6 +399,7 @@ public class PersistentAttributesEnhancer extends Enhancer {
|
||||||
" }%n",
|
" }%n",
|
||||||
newAssociationLoaded,
|
newAssociationLoaded,
|
||||||
targetEntity.getName(),
|
targetEntity.getName(),
|
||||||
|
targetEntity.getName(),
|
||||||
targetElementLoaded,
|
targetElementLoaded,
|
||||||
mappedByGetterName
|
mappedByGetterName
|
||||||
)
|
)
|
||||||
|
@ -537,16 +538,18 @@ public class PersistentAttributesEnhancer extends Enhancer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- //
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace access to fields of entities (for example, entity.field) with a call to the enhanced getter / setter
|
* Replace access to fields of entities (for example, entity.field) with a call to the enhanced getter / setter
|
||||||
* (in this example, entity.$$_hibernate_read_field()). It's assumed that the target entity is enhanced as well.
|
* (in this example, entity.$$_hibernate_read_field()). It's assumed that the target entity is enhanced as well.
|
||||||
*
|
*
|
||||||
* @param managedCtClass Class to enhance
|
* @param aCtClass Class to enhance (not an entity class).
|
||||||
*/
|
*/
|
||||||
public void enhanceFieldAccess(CtClass managedCtClass) {
|
public void extendedEnhancement(CtClass aCtClass) {
|
||||||
final ConstPool constPool = managedCtClass.getClassFile().getConstPool();
|
final ConstPool constPool = aCtClass.getClassFile().getConstPool();
|
||||||
|
|
||||||
for ( Object oMethod : managedCtClass.getClassFile().getMethods() ) {
|
for ( Object oMethod : aCtClass.getClassFile().getMethods() ) {
|
||||||
final MethodInfo methodInfo = (MethodInfo) oMethod;
|
final MethodInfo methodInfo = (MethodInfo) oMethod;
|
||||||
final String methodName = methodInfo.getName();
|
final String methodName = methodInfo.getName();
|
||||||
|
|
||||||
|
@ -570,14 +573,18 @@ public class PersistentAttributesEnhancer extends Enhancer {
|
||||||
if ( !enhancementContext.isEntityClass( targetCtClass ) && !enhancementContext.isCompositeClass( targetCtClass ) ) {
|
if ( !enhancementContext.isEntityClass( targetCtClass ) && !enhancementContext.isCompositeClass( targetCtClass ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( targetCtClass == managedCtClass
|
if ( targetCtClass == aCtClass
|
||||||
|| !enhancementContext.isPersistentField( targetCtClass.getField( fieldName ) )
|
|| !enhancementContext.isPersistentField( targetCtClass.getField( fieldName ) )
|
||||||
|| PersistentAttributesHelper.hasAnnotation( targetCtClass, fieldName, Id.class )
|
|| PersistentAttributesHelper.hasAnnotation( targetCtClass, fieldName, Id.class )
|
||||||
|| "this$0".equals( fieldName ) ) {
|
|| "this$0".equals( fieldName ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debugf( "Transforming access to field [%s] from method [%s]", fieldName, methodName );
|
log.debugf( "Extended enhancement: Transforming access to field [%s.%s] from method [%s#%s]",
|
||||||
|
fieldClassName,
|
||||||
|
fieldName,
|
||||||
|
aCtClass.getName(),
|
||||||
|
methodName );
|
||||||
|
|
||||||
if ( op == Opcode.GETFIELD ) {
|
if ( op == Opcode.GETFIELD ) {
|
||||||
int fieldReaderMethodIndex = constPool.addMethodrefInfo(
|
int fieldReaderMethodIndex = constPool.addMethodrefInfo(
|
||||||
|
@ -603,14 +610,14 @@ public class PersistentAttributesEnhancer extends Enhancer {
|
||||||
}
|
}
|
||||||
catch (BadBytecode bb) {
|
catch (BadBytecode bb) {
|
||||||
final String msg = String.format(
|
final String msg = String.format(
|
||||||
"Unable to perform field access transformation in method [%s]",
|
"Unable to perform extended enhancement in method [%s]",
|
||||||
methodName
|
methodName
|
||||||
);
|
);
|
||||||
throw new EnhancementException( msg, bb );
|
throw new EnhancementException( msg, bb );
|
||||||
}
|
}
|
||||||
catch (NotFoundException nfe) {
|
catch (NotFoundException nfe) {
|
||||||
final String msg = String.format(
|
final String msg = String.format(
|
||||||
"Unable to perform field access transformation in method [%s]",
|
"Unable to perform extended enhancement in method [%s]",
|
||||||
methodName
|
methodName
|
||||||
);
|
);
|
||||||
throw new EnhancementException( msg, nfe );
|
throw new EnhancementException( msg, nfe );
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class DefaultEnhancementContext implements EnhancementContext {
|
||||||
/**
|
/**
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
public boolean doFieldAccessEnhancement(CtClass classDescriptor) {
|
public boolean doExtendedEnhancement(CtClass classDescriptor) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ public interface EnhancementContext {
|
||||||
* @return {@code true} indicates that any direct access to fields of entities should be routed to the enhanced
|
* @return {@code true} indicates that any direct access to fields of entities should be routed to the enhanced
|
||||||
* getter / setter method.
|
* getter / setter method.
|
||||||
*/
|
*/
|
||||||
public boolean doFieldAccessEnhancement(CtClass classDescriptor);
|
public boolean doExtendedEnhancement(CtClass classDescriptor);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does the given class define any lazy loadable attributes?
|
* Does the given class define any lazy loadable attributes?
|
||||||
|
|
|
@ -146,9 +146,9 @@ public class Enhancer {
|
||||||
log.debugf( "Enhancing [%s] as Composite", managedCtClass.getName() );
|
log.debugf( "Enhancing [%s] as Composite", managedCtClass.getName() );
|
||||||
new CompositeEnhancer( enhancementContext ).enhance( managedCtClass );
|
new CompositeEnhancer( enhancementContext ).enhance( managedCtClass );
|
||||||
}
|
}
|
||||||
else if ( enhancementContext.doFieldAccessEnhancement( managedCtClass ) ) {
|
else if ( enhancementContext.doExtendedEnhancement( managedCtClass ) ) {
|
||||||
log.debugf( "Enhancing field access in [%s]", managedCtClass.getName() );
|
log.debugf( "Extended enhancement of [%s]", managedCtClass.getName() );
|
||||||
new PersistentAttributesEnhancer( enhancementContext ).enhanceFieldAccess( managedCtClass );
|
new PersistentAttributesEnhancer( enhancementContext ).extendedEnhancement( managedCtClass );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.debugf( "Skipping enhancement of [%s]: not entity or composite", managedCtClass.getName() );
|
log.debugf( "Skipping enhancement of [%s]: not entity or composite", managedCtClass.getName() );
|
||||||
|
|
|
@ -185,7 +185,7 @@ public class EnhancementTask extends Task implements EnhancementContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doFieldAccessEnhancement(CtClass classDescriptor) {
|
public boolean doExtendedEnhancement(CtClass classDescriptor) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,8 @@ import org.hibernate.test.bytecode.enhancement.association.OneToOneAssociationTe
|
||||||
import org.hibernate.test.bytecode.enhancement.basic.BasicEnhancementTestTask;
|
import org.hibernate.test.bytecode.enhancement.basic.BasicEnhancementTestTask;
|
||||||
import org.hibernate.test.bytecode.enhancement.basic.HHH9529TestTask;
|
import org.hibernate.test.bytecode.enhancement.basic.HHH9529TestTask;
|
||||||
import org.hibernate.test.bytecode.enhancement.dirty.DirtyTrackingTestTask;
|
import org.hibernate.test.bytecode.enhancement.dirty.DirtyTrackingTestTask;
|
||||||
import org.hibernate.test.bytecode.enhancement.field.FieldAccessBidirectionalTestTasK;
|
import org.hibernate.test.bytecode.enhancement.extended.ExtendedAssociationManagementTestTasK;
|
||||||
import org.hibernate.test.bytecode.enhancement.field.FieldAccessEnhancementTestTask;
|
import org.hibernate.test.bytecode.enhancement.extended.ExtendedEnhancementTestTask;
|
||||||
import org.hibernate.test.bytecode.enhancement.join.HHH3949TestTask1;
|
import org.hibernate.test.bytecode.enhancement.join.HHH3949TestTask1;
|
||||||
import org.hibernate.test.bytecode.enhancement.join.HHH3949TestTask2;
|
import org.hibernate.test.bytecode.enhancement.join.HHH3949TestTask2;
|
||||||
import org.hibernate.test.bytecode.enhancement.join.HHH3949TestTask3;
|
import org.hibernate.test.bytecode.enhancement.join.HHH3949TestTask3;
|
||||||
|
@ -106,9 +106,9 @@ public class EnhancerTest extends BaseUnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFieldAccess() {
|
public void testExtendedEnhancement() {
|
||||||
EnhancerTestUtils.runEnhancerTestTask( FieldAccessEnhancementTestTask.class );
|
EnhancerTestUtils.runEnhancerTestTask( ExtendedEnhancementTestTask.class );
|
||||||
EnhancerTestUtils.runEnhancerTestTask( FieldAccessBidirectionalTestTasK.class );
|
EnhancerTestUtils.runEnhancerTestTask( ExtendedAssociationManagementTestTasK.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.bytecode.enhancement.field;
|
package org.hibernate.test.bytecode.enhancement.extended;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
@ -12,14 +12,14 @@ import javax.persistence.FetchType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.OneToOne;
|
import javax.persistence.OneToOne;
|
||||||
|
|
||||||
import org.hibernate.test.bytecode.enhancement.AbstractEnhancerTestTask;
|
|
||||||
import org.hibernate.testing.bytecode.enhancement.EnhancerTestUtils;
|
import org.hibernate.testing.bytecode.enhancement.EnhancerTestUtils;
|
||||||
|
import org.hibernate.test.bytecode.enhancement.AbstractEnhancerTestTask;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luis Barreiro
|
* @author Luis Barreiro
|
||||||
*/
|
*/
|
||||||
public class FieldAccessBidirectionalTestTasK extends AbstractEnhancerTestTask {
|
public class ExtendedAssociationManagementTestTasK extends AbstractEnhancerTestTask {
|
||||||
|
|
||||||
public Class<?>[] getAnnotatedClasses() {
|
public Class<?>[] getAnnotatedClasses() {
|
||||||
return new Class<?>[] {Customer.class, User.class};
|
return new Class<?>[] {Customer.class, User.class};
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.bytecode.enhancement.field;
|
package org.hibernate.test.bytecode.enhancement.extended;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -15,15 +15,15 @@ import javax.persistence.OneToMany;
|
||||||
|
|
||||||
import org.hibernate.engine.spi.PersistentAttributeInterceptable;
|
import org.hibernate.engine.spi.PersistentAttributeInterceptable;
|
||||||
|
|
||||||
import org.hibernate.test.bytecode.enhancement.AbstractEnhancerTestTask;
|
|
||||||
import org.hibernate.testing.bytecode.enhancement.EnhancerTestUtils;
|
import org.hibernate.testing.bytecode.enhancement.EnhancerTestUtils;
|
||||||
|
import org.hibernate.test.bytecode.enhancement.AbstractEnhancerTestTask;
|
||||||
import org.hibernate.test.bytecode.enhancement.basic.ObjectAttributeMarkerInterceptor;
|
import org.hibernate.test.bytecode.enhancement.basic.ObjectAttributeMarkerInterceptor;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luis Barreiro
|
* @author Luis Barreiro
|
||||||
*/
|
*/
|
||||||
public class FieldAccessEnhancementTestTask extends AbstractEnhancerTestTask {
|
public class ExtendedEnhancementTestTask extends AbstractEnhancerTestTask {
|
||||||
|
|
||||||
public Class<?>[] getAnnotatedClasses() {
|
public Class<?>[] getAnnotatedClasses() {
|
||||||
return new Class<?>[] {SimpleEntity.class};
|
return new Class<?>[] {SimpleEntity.class};
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.bytecode.enhancement.pk;
|
package org.hibernate.test.bytecode.enhancement.pk;
|
||||||
|
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
|
|
|
@ -1,134 +1,62 @@
|
||||||
/*
|
/*
|
||||||
* SPECjEnterprise2010 - a benchmark for enterprise middleware
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
* Copyright 1995-2010 Standard Performance Evaluation Corporation
|
*
|
||||||
* All Rights Reserved
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||||
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.hibernate.test.bytecode.enhancement.pk;
|
package org.hibernate.test.bytecode.enhancement.pk;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.GenerationType;
|
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.IdClass;
|
import javax.persistence.IdClass;
|
||||||
import javax.persistence.NamedQueries;
|
|
||||||
import javax.persistence.NamedQuery;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
import javax.persistence.TableGenerator;
|
|
||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
import javax.persistence.Version;
|
import javax.persistence.Version;
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
|
||||||
import javax.xml.bind.annotation.XmlSchemaType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represent a work order that evolves through multiple processing stages.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
|
||||||
@NamedQueries({
|
|
||||||
@NamedQuery(name=WorkOrder.QUERY_ALL,
|
|
||||||
query="select w from WorkOrder w"),
|
|
||||||
// @NamedQuery(name=WorkOrder.QUERY_BY_STATUS,
|
|
||||||
// query="select w from WorkOrder w where w.status = :status"),
|
|
||||||
@NamedQuery(name=WorkOrder.QUERY_BY_OID_OLID,
|
|
||||||
query="select w from WorkOrder w where w.location = :location and w.salesId = :salesId and w.orderLineId = :orderLineId"),
|
|
||||||
@NamedQuery(name=WorkOrder.QUERY_COUNT,
|
|
||||||
query="select COUNT(a) from WorkOrder a")
|
|
||||||
})
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "M_WORKORDER")
|
|
||||||
@XmlAccessorType(XmlAccessType.PROPERTY)
|
|
||||||
@IdClass(WorkOrderPK.class)
|
@IdClass(WorkOrderPK.class)
|
||||||
public class WorkOrder {
|
public class WorkOrder {
|
||||||
|
|
||||||
public static final String QUERY_ALL = "WorkOrder.selectAll";
|
|
||||||
//public static final String QUERY_BY_STATUS = "WorkOrder.selectByStatus";
|
|
||||||
public static final String QUERY_BY_OID_OLID = "WorkOrder.selectByOID_OLID";
|
|
||||||
public static final String QUERY_COUNT = "WorkOrder.count";
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@TableGenerator(name = "workorder",
|
|
||||||
table = "U_SEQUENCES",
|
|
||||||
pkColumnName = "S_ID",
|
|
||||||
valueColumnName = "S_NEXTNUM",
|
|
||||||
pkColumnValue = "workorder",
|
|
||||||
allocationSize = 1000)
|
|
||||||
@GeneratedValue(strategy = GenerationType.TABLE, generator = "workorder")
|
|
||||||
@Column(name = "WO_NUMBER")
|
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "WO_LOCATION")
|
|
||||||
private int location;
|
private int location;
|
||||||
|
|
||||||
@Column(name = "WO_O_ID")
|
|
||||||
private int salesId;
|
|
||||||
|
|
||||||
@Column(name = "WO_OL_ID")
|
|
||||||
private int orderLineId;
|
|
||||||
|
|
||||||
@Column(name = "WO_ORIG_QTY")
|
|
||||||
private int originalQuantity;
|
private int originalQuantity;
|
||||||
|
|
||||||
@Column(name = "WO_COMP_QTY")
|
|
||||||
private int completedQuantity;
|
private int completedQuantity;
|
||||||
|
|
||||||
@Column(name = "WO_DUE_DATE")
|
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Calendar dueDate;
|
private Calendar dueDate;
|
||||||
|
|
||||||
@Column(name = "WO_START_DATE")
|
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
private Calendar startDate;
|
private Calendar startDate;
|
||||||
|
|
||||||
@Column(name = "WO_ASSEMBLY_ID")
|
|
||||||
private String assemblyId;
|
private String assemblyId;
|
||||||
|
|
||||||
@Version
|
@Version
|
||||||
@Column(name = "WO_VERSION")
|
|
||||||
private int version;
|
private int version;
|
||||||
|
|
||||||
/**
|
|
||||||
* Public no-arg constructor required by JAXB specification.
|
|
||||||
*/
|
|
||||||
public WorkOrder() {
|
public WorkOrder() {
|
||||||
this("", 1, 0, Calendar.getInstance());
|
this("", 1, 0, Calendar.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct with proper state. The status at construction is OPEN.
|
|
||||||
* @param location
|
|
||||||
*/
|
|
||||||
public WorkOrder(String assemblyId, int origQty, int location, Calendar dueDate) {
|
public WorkOrder(String assemblyId, int origQty, int location, Calendar dueDate) {
|
||||||
if (origQty < 1)
|
if (origQty < 1)
|
||||||
throw new IllegalArgumentException("WorkOrder can not be created " +
|
throw new IllegalArgumentException("WorkOrder can not be created with original quantity " + origQty + ". Must be > 0");
|
||||||
" with original quantity " + origQty + ". Must be > 0");
|
|
||||||
if (dueDate == null)
|
if (dueDate == null)
|
||||||
throw new IllegalArgumentException("WorkOrder can not be created " +
|
throw new IllegalArgumentException("WorkOrder can not be created with null due Date");
|
||||||
" with null due Date");
|
|
||||||
this.assemblyId = assemblyId;
|
this.assemblyId = assemblyId;
|
||||||
originalQuantity = origQty;
|
this.originalQuantity = origQty;
|
||||||
this.dueDate = dueDate;
|
this.dueDate = dueDate;
|
||||||
this.location=location;
|
this.location=location;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct with proper state. The status at construction is OPEN.
|
|
||||||
* @param location
|
|
||||||
*/
|
|
||||||
public WorkOrder(String assemblyId, int salesId, int oLineId, int origQty,
|
|
||||||
int location, Calendar dueDate) {
|
|
||||||
this(assemblyId, origQty, location, dueDate);
|
|
||||||
this.salesId = salesId;
|
|
||||||
orderLineId = oLineId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -137,6 +65,8 @@ public class WorkOrder {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- //
|
||||||
|
|
||||||
public String getAssemblyId() {
|
public String getAssemblyId() {
|
||||||
return assemblyId;
|
return assemblyId;
|
||||||
}
|
}
|
||||||
|
@ -153,23 +83,14 @@ public class WorkOrder {
|
||||||
return dueDate;
|
return dueDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOrderLineId() {
|
|
||||||
return orderLineId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getOriginalQuantity() {
|
public int getOriginalQuantity() {
|
||||||
return originalQuantity;
|
return originalQuantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSalesId() {
|
|
||||||
return salesId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLocation() {
|
public int getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlSchemaType(name = "dateTime")
|
|
||||||
public Calendar getStartDate() {
|
public Calendar getStartDate() {
|
||||||
return startDate;
|
return startDate;
|
||||||
}
|
}
|
||||||
|
@ -178,9 +99,30 @@ public class WorkOrder {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================================================================
|
// --- //
|
||||||
|
|
||||||
|
public void setStartDate(Calendar instance) {
|
||||||
|
startDate = instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocation(int location) {
|
||||||
|
this.location = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDueDate(Calendar dueDate) {
|
||||||
|
this.dueDate = dueDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAssemblyId(String assemblyId) {
|
||||||
|
this.assemblyId = assemblyId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOriginalQuantity(int originalQuantity) {
|
||||||
|
this.originalQuantity = originalQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
// Processing methods
|
// Processing methods
|
||||||
// ======================================================================
|
|
||||||
/**
|
/**
|
||||||
* Moves to the next state of processing.
|
* Moves to the next state of processing.
|
||||||
* Return true if the new status can be updated again.
|
* Return true if the new status can be updated again.
|
||||||
|
@ -203,6 +145,8 @@ public class WorkOrder {
|
||||||
public void setStatusCancelled() {
|
public void setStatusCancelled() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- //
|
||||||
|
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (this == other)
|
if (this == other)
|
||||||
return true;
|
return true;
|
||||||
|
@ -216,37 +160,8 @@ public class WorkOrder {
|
||||||
return PRIME * new Integer(id).hashCode();
|
return PRIME * new Integer(id).hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "WorkOrder:["+ getId() + "]" ;
|
return "WorkOrder:["+ getId() + "]" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStartDate(Calendar instance) {
|
|
||||||
startDate = instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLocation(int location) {
|
|
||||||
this.location = location;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDueDate(Calendar dueDate) {
|
|
||||||
this.dueDate = dueDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAssemblyId(String assemblyId) {
|
|
||||||
this.assemblyId = assemblyId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOriginalQuantity(int originalQuantity) {
|
|
||||||
this.originalQuantity = originalQuantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSalesId(int salesId) {
|
|
||||||
this.salesId = salesId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrderLineId(int orderLineId) {
|
|
||||||
this.orderLineId = orderLineId;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* SPECjEnterprise2010 - a benchmark for enterprise middleware
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
* Copyright 1995-2010 Standard Performance Evaluation Corporation
|
|
||||||
* All Rights Reserved
|
|
||||||
*
|
*
|
||||||
* History:
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||||
* Date ID, Company Description
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
* ---------- ---------------- ----------------------------------------------
|
|
||||||
* 2009/05/31 Anoop Gupta, Oracle Created for SPECjEnterprise2010
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.hibernate.test.bytecode.enhancement.pk;
|
package org.hibernate.test.bytecode.enhancement.pk;
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class JpaRuntimeEnhancementTest extends BaseUnitTestCase {
|
||||||
// public ClassLoader buildIsolatedClassLoader() {
|
// public ClassLoader buildIsolatedClassLoader() {
|
||||||
// final EnhancementContext enhancementContext = new DefaultEnhancementContext() {
|
// final EnhancementContext enhancementContext = new DefaultEnhancementContext() {
|
||||||
// @Override
|
// @Override
|
||||||
// public boolean doFieldAccessEnhancement(CtClass classDescriptor) {
|
// public boolean doExtendedEnhancement(CtClass classDescriptor) {
|
||||||
// return classDescriptor.getPackageName().startsWith( "org.hibernate.jpa.test.enhancement.domain" );
|
// return classDescriptor.getPackageName().startsWith( "org.hibernate.jpa.test.enhancement.domain" );
|
||||||
// }
|
// }
|
||||||
// };
|
// };
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.hibernate.bytecode.enhance.spi.DefaultEnhancementContext;
|
||||||
public class EnhancerTestContext extends DefaultEnhancementContext {
|
public class EnhancerTestContext extends DefaultEnhancementContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doFieldAccessEnhancement(CtClass classDescriptor) {
|
public boolean doExtendedEnhancement(CtClass classDescriptor) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,11 +70,11 @@ public class MavenEnhancePlugin extends AbstractMojo {
|
||||||
@Parameter(property = "enableAssociationManagement", defaultValue = "true")
|
@Parameter(property = "enableAssociationManagement", defaultValue = "true")
|
||||||
private boolean enableAssociationManagement = true;
|
private boolean enableAssociationManagement = true;
|
||||||
|
|
||||||
@Parameter(property = "enableFieldAccessEnhancement", defaultValue = "false")
|
@Parameter(property = "enableExtendedEnhancement", defaultValue = "false")
|
||||||
private boolean enableFieldAccessEnhancement = false;
|
private boolean enableExtendedEnhancement = false;
|
||||||
|
|
||||||
private boolean shouldApply() {
|
private boolean shouldApply() {
|
||||||
return enableLazyInitialization || enableDirtyTracking || enableAssociationManagement || enableFieldAccessEnhancement;
|
return enableLazyInitialization || enableDirtyTracking || enableAssociationManagement || enableExtendedEnhancement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
public void execute() throws MojoExecutionException, MojoFailureException {
|
||||||
|
@ -125,11 +125,15 @@ public class MavenEnhancePlugin extends AbstractMojo {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doFieldAccessEnhancement(CtClass classDescriptor) {
|
public boolean doExtendedEnhancement(CtClass classDescriptor) {
|
||||||
return enableFieldAccessEnhancement;
|
return enableExtendedEnhancement;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if ( enableExtendedEnhancement ) {
|
||||||
|
getLog().warn( "Extended enhancement is enabled. Classes other than entities may be modified. You should consider access the entities using getter/setter methods and disable this property. Use at your own risk." );
|
||||||
|
}
|
||||||
|
|
||||||
final Enhancer enhancer = new Enhancer( enhancementContext );
|
final Enhancer enhancer = new Enhancer( enhancementContext );
|
||||||
final ClassPool classPool = new ClassPool( false );
|
final ClassPool classPool = new ClassPool( false );
|
||||||
|
|
||||||
|
|
|
@ -111,11 +111,15 @@ public class HibernatePlugin implements Plugin<Project> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doFieldAccessEnhancement(CtClass classDescriptor) {
|
public boolean doExtendedEnhancement(CtClass classDescriptor) {
|
||||||
return hibernateExtension.enhance.getEnableFieldAccessEnhancement();
|
return hibernateExtension.enhance.getEnableFieldAccessEnhancement();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if ( hibernateExtension.enhance.getEnableFieldAccessEnhancement() ) {
|
||||||
|
logger.warn( "Extended enhancement is enabled. Classes other than entities may be modified. You should consider access the entities using getter/setter methods and disable this property. Use at your own risk." );
|
||||||
|
}
|
||||||
|
|
||||||
final Enhancer enhancer = new Enhancer( enhancementContext );
|
final Enhancer enhancer = new Enhancer( enhancementContext );
|
||||||
final ClassPool classPool = new ClassPool( false );
|
final ClassPool classPool = new ClassPool( false );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue