001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.orm.hibernate.tuplizer.proxy; 020 021import java.io.Serializable; 022 023import lucee.runtime.Component; 024import lucee.runtime.ComponentPro; 025import lucee.runtime.exp.PageException; 026import lucee.runtime.type.ObjectWrap; 027 028import org.hibernate.proxy.HibernateProxy; 029import org.hibernate.proxy.LazyInitializer; 030 031 032 033/** 034 * Proxy for "dynamic-map" entity representations. 035 * SLOW 036 */ 037public class CFCHibernateProxy extends ComponentProProxy implements HibernateProxy, Serializable,ObjectWrap { 038 039 private static final long serialVersionUID = 4115236247834562085L; 040 041 private CFCLazyInitializer li; 042 043 @Override 044 public Component getComponent() { 045 return li.getCFC(); 046 } 047 048 @Override 049 public ComponentPro getComponentPro() { 050 return (ComponentPro) li.getCFC(); 051 } 052 053 public CFCHibernateProxy(CFCLazyInitializer li) { 054 this.li = li; 055 } 056 057 @Override 058 public Object writeReplace() { 059 return this; 060 } 061 062 @Override 063 public LazyInitializer getHibernateLazyInitializer() { 064 return li; 065 } 066 067 @Override 068 public Object getEmbededObject(Object defaultValue) { 069 return getComponent(); 070 } 071 072 @Override 073 public Object getEmbededObject() throws PageException { 074 return getComponent(); 075 } 076}