net.java.ao
Class ReadOnlyEntityProxy<T extends RawEntity<K>,K>

java.lang.Object
  extended by net.java.ao.ReadOnlyEntityProxy<T,K>
Type Parameters:
T - the type of Entity
K - the primary key type
All Implemented Interfaces:
InvocationHandler

public class ReadOnlyEntityProxy<T extends RawEntity<K>,K>
extends Object
implements InvocationHandler

A read-only representation of a database row proxy, mapped to the specified Entity type.

This implementation is used for streaming and intended to be as lightweight as possible. It only supports getters or designated Accessor methods. Calling setters or save will result in an exception. Other method calls will be ignored.

As much as possible, reflection calls should be kept out of this implementation. If there is information needed about the implemented type, please use ReadOnlyEntityProxyFactory to cache them.

TODO There is currently some overlap with EntityProxy. As soon as this is battle-hardened, these can be refactored into an abstract superclass, for example.

Author:
ahennecke

Constructor Summary
ReadOnlyEntityProxy(EntityManager manager, Class<T> type, K key, Map<Method,String> fieldNames, Map<String,String> polymorphicFieldNames, Map<String,Class<?>> returnTypes, Set<Method> accessors)
           
 
Method Summary
 void addValue(String fieldName, ResultSet res)
           
 boolean equals(Object obj)
           
 boolean equalsImpl(RawEntity<K> proxy, Object obj)
           
 K getKey()
           
 int hashCode()
           
 int hashCodeImpl()
           
 Object invoke(Object proxy, Method method, Object[] args)
           
 String toStringImpl()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReadOnlyEntityProxy

public ReadOnlyEntityProxy(EntityManager manager,
                           Class<T> type,
                           K key,
                           Map<Method,String> fieldNames,
                           Map<String,String> polymorphicFieldNames,
                           Map<String,Class<?>> returnTypes,
                           Set<Method> accessors)
Method Detail

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Specified by:
invoke in interface InvocationHandler
Throws:
Throwable

addValue

public void addValue(String fieldName,
                     ResultSet res)
              throws SQLException
Throws:
SQLException

getKey

public K getKey()

hashCodeImpl

public int hashCodeImpl()

equalsImpl

public boolean equalsImpl(RawEntity<K> proxy,
                          Object obj)

toStringImpl

public String toStringImpl()

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2007-2011. All Rights Reserved.