Java Code Examples for org.hibernate.Hibernate#isPropertyInitialized()

The following examples show how to use org.hibernate.Hibernate#isPropertyInitialized() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HibernateTraversableResolver.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public boolean isReachable(Object traversableObject,
		Path.Node traversableProperty,
		Class<?> rootBeanType,
		Path pathToTraversableObject,
		ElementType elementType) {
	//lazy, don't load
	return Hibernate.isInitialized( traversableObject )
			&& Hibernate.isPropertyInitialized( traversableObject, traversableProperty.getName() );
}
 
Example 2
Source File: CodeTemplates.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Advice.OnMethodEnter
static void enter(@FieldValue Collection<?> field, @Advice.Argument(0) Collection<?> argument, @MappedBy String mappedBy) {
	if ( field != null && Hibernate.isPropertyInitialized( field, mappedBy ) ) {
		Object[] array = field.toArray();
		for ( int i = 0; i < array.length; i++ ) {
			if ( argument == null || !argument.contains( array[i] ) ) {
				setterNull( array[i], null );
			}
		}
	}
}
 
Example 3
Source File: CodeTemplates.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Advice.OnMethodExit
static void exit(@Advice.This Object self, @Advice.Argument(0) Collection<?> argument, @MappedBy String mappedBy) {
	if ( argument != null && Hibernate.isPropertyInitialized( argument, mappedBy ) ) {
		Object[] array = argument.toArray();
		for ( int i = 0; i < array.length; i++ ) {
			if ( Hibernate.isPropertyInitialized( array[i], mappedBy ) && getter( array[i] ) != self ) {
				setterSelf( array[i], self );
			}
		}
	}
}
 
Example 4
Source File: CodeTemplates.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Advice.OnMethodEnter
static void enter(@FieldValue Map<?, ?> field, @Advice.Argument(0) Map<?, ?> argument, @MappedBy String mappedBy) {
	if ( field != null && Hibernate.isPropertyInitialized( field, mappedBy ) ) {
		Object[] array = field.values().toArray();
		for ( int i = 0; i < array.length; i++ ) {
			if ( argument == null || !argument.values().contains( array[i] ) ) {
				setterNull( array[i], null );
			}
		}
	}
}
 
Example 5
Source File: CodeTemplates.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Advice.OnMethodExit
static void exit(@Advice.This Object self, @Advice.Argument(0) Map<?, ?> argument, @MappedBy String mappedBy) {
	if ( argument != null && Hibernate.isPropertyInitialized( argument, mappedBy ) ) {
		Object[] array = argument.values().toArray();
		for ( int i = 0; i < array.length; i++ ) {
			if ( Hibernate.isPropertyInitialized( array[i], mappedBy ) && getter( array[i] ) != self ) {
				setterSelf( array[i], self );
			}
		}
	}
}
 
Example 6
Source File: CodeTemplates.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Advice.OnMethodEnter
static void enter(@Advice.This Object self, @FieldValue Object field, @MappedBy String mappedBy) {
	if ( field != null && Hibernate.isPropertyInitialized( field, mappedBy ) ) {
		Collection<?> c = getter( field );
		if ( c != null ) {
			c.remove( self );
		}
	}
}
 
Example 7
Source File: CodeTemplates.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Advice.OnMethodExit
static void exit(@Advice.This Object self, @Advice.Argument(0) Object argument, @MappedBy String mappedBy) {
	if ( argument != null && Hibernate.isPropertyInitialized( argument, mappedBy ) ) {
		Collection<Object> c = getter( argument );
		if ( c != null && !c.contains( self ) ) {
			c.add( self );
		}
	}
}
 
Example 8
Source File: CodeTemplates.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Advice.OnMethodEnter
static void enter(@Advice.This Object self, @FieldValue Collection<?> field, @Advice.Argument(0) Collection<?> argument, @MappedBy String mappedBy) {
	if ( field != null && Hibernate.isPropertyInitialized( field, mappedBy ) ) {
		Object[] array = field.toArray();
		for ( int i = 0; i < array.length; i++ ) {
			if ( argument == null || !argument.contains( array[i] ) ) {
				getter( array[i] ).remove( self );
			}
		}
	}
}
 
Example 9
Source File: CodeTemplates.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Advice.OnMethodExit
static void exit(@Advice.This Object self, @Advice.Argument(0) Collection<?> argument, @MappedBy String mappedBy) {
	if ( argument != null && Hibernate.isPropertyInitialized( argument, mappedBy ) ) {
		Object[] array = argument.toArray();
		for ( int i = 0; i < array.length; i++ ) {
			if ( Hibernate.isPropertyInitialized( array[i], mappedBy ) ) {
				Collection<Object> c = getter( array[i] );
				if ( c != self && c != null ) {
					c.add( self );
				}
			}
		}
	}
}
 
Example 10
Source File: Location.java    From unitime with Apache License 2.0 5 votes vote down vote up
@Deprecated
  public String getHtmlHint(String preference) {
try {
	if (!Hibernate.isPropertyInitialized(this, "roomType") || !Hibernate.isInitialized(getRoomType())) {
		return LocationDAO.getInstance().get(getUniqueId()).getHtmlHintImpl(preference);
	} else {
		return getHtmlHintImpl(preference);
	}
} catch (LazyInitializationException e) {
	return LocationDAO.getInstance().get(getUniqueId()).getHtmlHintImpl(preference);
}
  }
 
Example 11
Source File: CodeTemplates.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Advice.OnMethodEnter
static void enter(@FieldValue Object field, @Advice.Argument(0) Object argument, @MappedBy String mappedBy) {
	if ( field != null && Hibernate.isPropertyInitialized( field, mappedBy ) && argument != null ) {
		setterNull( field, null );
	}
}
 
Example 12
Source File: CodeTemplates.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Advice.OnMethodExit
static void exit(@Advice.This Object self, @Advice.Argument(0) Object argument, @MappedBy String mappedBy) {
	if ( argument != null && Hibernate.isPropertyInitialized( argument, mappedBy ) && getter( argument ) != self ) {
		setterSelf( argument, self );
	}
}