ome.tools.hibernate
Class HibernateUtils

java.lang.Object
  extended by ome.tools.hibernate.HibernateUtils

public abstract class HibernateUtils
extends Object

contains methods for reloading unloaded entities and nulled collections as well as determining the index of certain properties in a dehydrated Hiberante array.

Since:
3.0-M3
Version:
$Revision: 3753 $, $Date: 2009-02-24 10:28:20 +0000 (Tue, 24 Feb 2009) $
Author:
Josh Moore, josh.moore at gmx.de
See Also:
wiki:ObjectModel

Constructor Summary
HibernateUtils()
           
 
Method Summary
protected static Collection copy(Collection c)
           
protected static Map copy(Map m)
           
static int detailsIndex(String[] propertyNames)
           
static void fixNulledOrFilteredCollections(ome.model.IObject entity, ome.model.IObject target, org.hibernate.persister.entity.EntityPersister persister, org.hibernate.engine.SessionImplementor source)
          loads collections which have been filtered or nulled by the user
static ome.model.internal.Details getDetails(Object[] state, String[] names)
           
static boolean idEqual(ome.model.IObject arg1, ome.model.IObject arg2)
          returns true under the following circumstatnces: both arguments are null, or both arguments are identical (==), or both arguments have the same id value(equals)
static int index(String str, String[] propertyNames)
           
static boolean isUnloaded(Object original)
           
static Long nullSafeGroupId(ome.model.IObject iobject)
          returns the id of the group of this entity, or null if: (1) the object is null, (2) the Details is null, (3) the group is null.
static Long nullSafeOwnerId(ome.model.IObject iobject)
          returns the id of the owner of this entity, or null if: (1) the object is null, (2) the Details is null, (3) the owner is null.
static boolean onlyLockChanged(org.hibernate.engine.SessionImplementor session, org.hibernate.persister.entity.EntityPersister persister, ome.model.IObject entity, Object[] state, String[] names)
          calculates if only the Permissions.Flag.LOCKED marker has been changed.
static boolean onlyPermissionsChanged(ome.model.internal.Details new_d, ome.model.internal.Details old_d)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateUtils

public HibernateUtils()
Method Detail

isUnloaded

public static boolean isUnloaded(Object original)

nullSafeOwnerId

public static Long nullSafeOwnerId(ome.model.IObject iobject)
returns the id of the owner of this entity, or null if: (1) the object is null, (2) the Details is null, (3) the owner is null.

Parameters:
iobject - Can be null.
Returns:
the id or null.

nullSafeGroupId

public static Long nullSafeGroupId(ome.model.IObject iobject)
returns the id of the group of this entity, or null if: (1) the object is null, (2) the Details is null, (3) the group is null.

Parameters:
iobject - Can be null.
Returns:
the id or null.

fixNulledOrFilteredCollections

public static void fixNulledOrFilteredCollections(ome.model.IObject entity,
                                                  ome.model.IObject target,
                                                  org.hibernate.persister.entity.EntityPersister persister,
                                                  org.hibernate.engine.SessionImplementor source)
loads collections which have been filtered or nulled by the user

Parameters:
entity - IObject to have its collections reloaded
id - persistent (db) id of this entity
currentState - the possibly changed field data for this entity
previousState - the field data as seen in the db
propertyNames - field names
types - Hibernate Type for each field
detailsIndex - the index of the Details instance (perf opt)

onlyLockChanged

public static boolean onlyLockChanged(org.hibernate.engine.SessionImplementor session,
                                      org.hibernate.persister.entity.EntityPersister persister,
                                      ome.model.IObject entity,
                                      Object[] state,
                                      String[] names)
calculates if only the Permissions.Flag.LOCKED marker has been changed. If not, the normal criteria apply. In the case of system types (the only types which can have null details) a true will be returned even though Permissions.Flag.LOCKED can't be set to prevent spurious SecurityViolation. This is due to ticket:307

See Also:
ticket:307

onlyPermissionsChanged

public static boolean onlyPermissionsChanged(ome.model.internal.Details new_d,
                                             ome.model.internal.Details old_d)
Parameters:
newD - Not null.
oldD - Not null.
Returns:

idEqual

public static boolean idEqual(ome.model.IObject arg1,
                              ome.model.IObject arg2)
returns true under the following circumstatnces:


getDetails

public static ome.model.internal.Details getDetails(Object[] state,
                                                    String[] names)

detailsIndex

public static int detailsIndex(String[] propertyNames)

index

public static int index(String str,
                        String[] propertyNames)

copy

protected static Map copy(Map m)

copy

protected static Collection copy(Collection c)


OmeroJava Api

Version: Beta-4.1.1-r5927-b91

Copyright © 2009 The University of Dundee. All Rights Reserved.