* public void _persistence_checkFetched(String attribute) { if - * (this._persistence_fetchGroup != null) { - * EntityManagerImpl.processUnfetchedAttribute(this, attribute); } } + * (!this._persistence_isAttributeFetched(var1)) { + * String var2 = this._persistence_getFetchGroup().onUnfetchedAttribute(this, var1); + * if (var2 != null) { + * throw new EntityNotFoundException(var2);}}} *
*
* public void _persistence_checkSetFetched(String attribute) { if
- * (this._persistence_fetchGroup != null) {
- * EntityManagerImpl.processUnfetchedAttributeForSet(this, attribute); } }
+ * if (!this._persistence_isAttributeFetched(var1)) {
+ * String var2 = this._persistence_getFetchGroup().onUnfetchedAttributeForSet(this, var1);
+ * if (var2 != null) {
+ * throw new EntityNotFoundException(var2);}}}
*/
public void addFetchGroupMethods(ClassDetails classDetails) {
MethodVisitor cv_getSession = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_getSession", "()" + SESSION_SIGNATURE, null, null);
@@ -1193,33 +1213,68 @@ public void addFetchGroupMethods(ClassDetails classDetails) {
cv_isAttributeFetched.visitInsn(Opcodes.valueInt("IRETURN"));
cv_isAttributeFetched.visitMaxs(0, 0);
- MethodVisitor cv_checkFetched = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_checkFetched", "(Ljava/lang/String;)V", null, null);
- cv_checkFetched.visitVarInsn(Opcodes.valueInt("ALOAD"), 0);
- cv_checkFetched.visitVarInsn(Opcodes.valueInt("ALOAD"), 1);
- cv_checkFetched.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), classDetails.getClassName(), "_persistence_isAttributeFetched", "(Ljava/lang/String;)Z", false);
- gotoReturn = ASMFactory.createLabel();
- cv_checkFetched.visitJumpInsn(Opcodes.valueInt("IFNE"), gotoReturn);
- cv_checkFetched.visitVarInsn(Opcodes.valueInt("ALOAD"), 0);
- cv_checkFetched.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), FETCHGROUP_TRACKER_SHORT_SIGNATURE);
- cv_checkFetched.visitVarInsn(Opcodes.valueInt("ALOAD"), 1);
- cv_checkFetched.visitMethodInsn(Opcodes.valueInt("INVOKESTATIC"), ENTITY_MANAGER_IMPL_SHORT_SIGNATURE, "processUnfetchedAttribute", "(" + FETCHGROUP_TRACKER_SIGNATURE + "Ljava/lang/String;)V", false);
- cv_checkFetched.visitLabel(gotoReturn);
- cv_checkFetched.visitInsn(Opcodes.valueInt("RETURN"));
- cv_checkFetched.visitMaxs(0, 0);
-
- MethodVisitor cv_checkFetchedForSet = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_checkFetchedForSet", "(Ljava/lang/String;)V", null, null);
- cv_checkFetchedForSet.visitVarInsn(Opcodes.valueInt("ALOAD"), 0);
- cv_checkFetchedForSet.visitVarInsn(Opcodes.valueInt("ALOAD"), 1);
- cv_checkFetchedForSet.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), classDetails.getClassName(), "_persistence_isAttributeFetched", "(Ljava/lang/String;)Z", false);
- gotoReturn = ASMFactory.createLabel();
- cv_checkFetchedForSet.visitJumpInsn(Opcodes.valueInt("IFNE"), gotoReturn);
- cv_checkFetchedForSet.visitVarInsn(Opcodes.valueInt("ALOAD"), 0);
- cv_checkFetchedForSet.visitTypeInsn(Opcodes.valueInt("CHECKCAST"), FETCHGROUP_TRACKER_SHORT_SIGNATURE);
- cv_checkFetchedForSet.visitVarInsn(Opcodes.valueInt("ALOAD"), 1);
- cv_checkFetchedForSet.visitMethodInsn(Opcodes.valueInt("INVOKESTATIC"), ENTITY_MANAGER_IMPL_SHORT_SIGNATURE, "processUnfetchedAttributeForSet", "(" + FETCHGROUP_TRACKER_SIGNATURE + "Ljava/lang/String;)V", false);
- cv_checkFetchedForSet.visitLabel(gotoReturn);
- cv_checkFetchedForSet.visitInsn(Opcodes.valueInt("RETURN"));
- cv_checkFetchedForSet.visitMaxs(0, 0);
+ MethodVisitor cv_checkFetched = cv.visitMethod(Opcodes.valueInt("ACC_PUBLIC"), "_persistence_checkFetched", "(" + STRING_SIGNATURE + ")V", null, null); {
+ Label l0 = ASMFactory.createLabel();
+ cv_checkFetched.visitLabel(l0);
+ // if (!this._persistence_isAttributeFetched(attributeName)) {
+ cv_checkFetched.visitVarInsn(Opcodes.valueInt("ALOAD"), 0);
+ cv_checkFetched.visitVarInsn(Opcodes.valueInt("ALOAD"), 1);
+ cv_checkFetched.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), classDetails.getClassName(), "_persistence_isAttributeFetched", "(" + STRING_SIGNATURE + ")Z", false);
+ Label l1 = ASMFactory.createLabel();
+ cv_checkFetched.visitJumpInsn(Opcodes.valueInt("IFNE"), l1);
+ // String errorMsg = _persistence_getFetchGroup().
+ cv_checkFetched.visitVarInsn(Opcodes.valueInt("ALOAD"), 0);
+ cv_checkFetched.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), classDetails.getClassName(), "_persistence_getFetchGroup", "()" + FETCHGROUP_SIGNATURE, false);
+ // .onUnfetchedAttribute(entity, attributeName);
+ cv_checkFetched.visitVarInsn(Opcodes.valueInt("ALOAD"), 0);
+ cv_checkFetched.visitVarInsn(Opcodes.valueInt("ALOAD"), 1);
+ cv_checkFetched.visitMethodInsn(Opcodes.valueInt("INVOKEVIRTUAL"), FETCHGROUP_SHORT_SIGNATURE, "onUnfetchedAttribute", "(" + FETCHGROUP_TRACKER_SIGNATURE + STRING_SIGNATURE + ")" + STRING_SIGNATURE, false);
+ cv_checkFetched.visitVarInsn(Opcodes.valueInt("ASTORE"), 2);
+ cv_checkFetched.visitVarInsn(Opcodes.valueInt("ALOAD"), 2);
+ cv_checkFetched.visitJumpInsn(Opcodes.valueInt("IFNULL"), l1);
+ // throw new EntityNotFoundException(errorMsg);
+ cv_checkFetched.visitTypeInsn(Opcodes.valueInt("NEW"), JPA_ENTITY_NOT_FOUND_EXCEPTION_SHORT_SIGNATURE);
+ cv_checkFetched.visitInsn(Opcodes.valueInt("DUP"));
+ cv_checkFetched.visitVarInsn(Opcodes.valueInt("ALOAD"), 2);
+ cv_checkFetched.visitMethodInsn(Opcodes.valueInt("INVOKESPECIAL"), JPA_ENTITY_NOT_FOUND_EXCEPTION_SHORT_SIGNATURE, "