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:
java.lang.reflect.InvocationHandler

public class ReadOnlyEntityProxy<T extends RawEntity<K>,K>
extends java.lang.Object
implements java.lang.reflect.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, java.lang.Class<T> type, K key, java.util.Map<java.lang.reflect.Method,java.lang.String> fieldNames, java.util.Map<java.lang.String,java.lang.String> polymorphicFieldNames, java.util.Map<java.lang.String,java.lang.Class<?>> returnTypes, java.util.Set<java.lang.reflect.Method> accessors)
           
 
Method Summary
 void addValue(java.lang.String fieldName, java.sql.ResultSet res)
           
 boolean equals(java.lang.Object obj)
           
 boolean equalsImpl(RawEntity<K> proxy, java.lang.Object obj)
           
 K getKey()
           
 int hashCode()
           
 int hashCodeImpl()
           
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
           
 java.lang.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,
                           java.lang.Class<T> type,
                           K key,
                           java.util.Map<java.lang.reflect.Method,java.lang.String> fieldNames,
                           java.util.Map<java.lang.String,java.lang.String> polymorphicFieldNames,
                           java.util.Map<java.lang.String,java.lang.Class<?>> returnTypes,
                           java.util.Set<java.lang.reflect.Method> accessors)
Method Detail

invoke

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

addValue

public void addValue(java.lang.String fieldName,
                     java.sql.ResultSet res)
              throws java.sql.SQLException
Throws:
java.sql.SQLException

getKey

public K getKey()

hashCodeImpl

public int hashCodeImpl()

equalsImpl

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

toStringImpl

public java.lang.String toStringImpl()

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © 2007-2012. All Rights Reserved.