1 17 package org.apache.ws.jaxme.sqls.junit; 18 19 import org.apache.ws.jaxme.sqls.BooleanConstraint; 20 import org.apache.ws.jaxme.sqls.CombinedConstraint; 21 import org.apache.ws.jaxme.sqls.SQLFactory; 22 import org.apache.ws.jaxme.sqls.SQLGenerator; 23 import org.apache.ws.jaxme.sqls.SelectTableReference; 24 import org.apache.ws.jaxme.sqls.Table; 25 import org.apache.ws.jaxme.sqls.oracle.OraColumnReference; 26 import org.apache.ws.jaxme.sqls.oracle.OraSQLFactoryImpl; 27 import org.apache.ws.jaxme.sqls.oracle.OraSQLGenerator; 28 import org.apache.ws.jaxme.sqls.oracle.OraSQLGeneratorImpl; 29 import org.apache.ws.jaxme.sqls.oracle.OraSelectStatement; 30 31 32 35 public class Oracle8Test extends CreateTest { 36 38 public Oracle8Test(String pName) { 39 super(pName); 40 } 41 42 protected SQLFactory newSQLFactory() { 43 return new OraSQLFactoryImpl(); 44 } 45 46 protected SQLGenerator newSQLGenerator() { 47 OraSQLGenerator gen = new OraSQLGeneratorImpl(); 48 gen.setOracle8Compatibility(true); 49 return gen; 50 } 51 52 protected String getTestJoinResult() { 53 return "SELECT OtherTable.MyIndex, RefIndex, Company FROM MySchema.OtherTable, MySchema.MyTable WHERE RefIndex=MyTable.MyIndex AND OtherTable.MyIndex=?"; 54 } 55 56 protected String getTestLeftOuterJoinResult() { 57 return "SELECT OtherTable.MyIndex, RefIndex, Company FROM MySchema.OtherTable, MySchema.MyTable WHERE RefIndex=MyTable.MyIndex(+) AND OtherTable.MyIndex=?"; 58 } 59 60 public void testConnectByPrior() { 61 Table table = getBasicTable(); 62 OraSelectStatement selectStatement = (OraSelectStatement) table.getSelectStatement(); 63 SelectTableReference ref = selectStatement.getSelectTableReference(); 64 CombinedConstraint startWith = selectStatement.getStartWith(); 65 BooleanConstraint bc = startWith.createEQ(); 66 bc.addPart(ref.newColumnReference("MyIndex")); 67 bc.addPart(1); 68 CombinedConstraint connectByPrior = selectStatement.getConnectBy(); 69 bc = connectByPrior.createEQ(); 70 OraColumnReference oraRef = (OraColumnReference) ref.newColumnReference("MyIndex"); 71 oraRef.setPrior(true); 72 bc.addPart(oraRef); 73 bc.addPart(ref.newColumnReference("MyName")); 74 SQLGenerator gen = getSQLGenerator(); 75 String query = gen.getQuery(selectStatement); 76 assertEquals("SELECT MyIndex, MyName, MyDate FROM MySchema.MyTable START WITH MyIndex=1 CONNECT BY PRIOR MyIndex=MyName", query); 77 } 78 79 protected String getBulkInsertResult() { 80 return "INSERT INTO MySchema.MyTable (MyTable.MyIndex, MyTable.MyName, MyTable.MyDate) (SELECT MyTable0.MyIndex, MyTable0.MyName, MyTable0.MyDate FROM MySchema.MyTable MyTable0)"; 81 } 82 } 83 | Popular Tags |