1 10 11 package com.triactive.jdo.store; 12 13 import com.triactive.jdo.PersistenceManager; 14 import java.sql.PreparedStatement ; 15 import java.sql.ResultSet ; 16 import javax.jdo.JDOUserException; 17 import javax.jdo.spi.PersistenceCapable; 18 19 20 public class PersistenceCapableMapping extends OIDMapping 21 { 22 private Class surroundingClass = null; 23 24 25 public PersistenceCapableMapping(DatabaseAdapter dba, Class type) 26 { 27 super(dba, type); 28 } 29 30 public PersistenceCapableMapping(Column col) 31 { 32 super(col); 33 } 34 35 public PersistenceCapableMapping(ClassBaseTable table, int relativeFieldNumber) 36 { 37 this(table.newColumn(relativeFieldNumber)); 38 39 surroundingClass = table.getType(); 40 } 41 42 public void setObject(PersistenceManager pm, PreparedStatement ps, int param, Object value) 43 { 44 pm.makePersistent(value); 45 super.setObject(pm, ps, param, pm.getObjectId(value)); 46 } 47 48 public Object getObject(PersistenceManager pm, ResultSet rs, int param) 49 { 50 return pm.getObjectById(super.getObject(pm, rs, param), surroundingClass, false); 51 } 52 53 public SQLExpression newSQLLiteral(QueryStatement qs, Object value) 54 { 55 return new ObjectLiteral(qs, this, value); 56 } 57 58 public SQLExpression newSQLExpression(QueryStatement qs, QueryStatement.QueryColumn qsc, String fieldName) 59 { 60 return new ObjectFieldExpression(qs, qsc, fieldName, type); 61 } 62 } 63 | Popular Tags |