/******************************************************************************* * Copyright (c) 1998, 2015 Oracle and/or its affiliates. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 * which accompanies this distribution. * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html * and the Eclipse Distribution License is available at * http://www.eclipse.org/org/documents/edl-v10.php. * * Contributors: * 07/23/2010-2.1.1 Chris Delahunt * - 316045 : eclipselink.jpa.uppercase-column-names is causing field names to be uppercase in generated SQL ******************************************************************************/ package org.eclipse.persistence.testing.models.jpa.advanced; import org.eclipse.persistence.tools.schemaframework.FieldDefinition; import org.eclipse.persistence.tools.schemaframework.TableDefinition; public class NativeQueryTableCreator extends AdvancedTableCreator { /* * TogglingFastTableCreator uses the name of the table creator class * as a key to control its functionality. * This table creator class and its super class share the same tables. * The super class name has to be passed to TogglingFastTableCreator to * ensure that, in case of 'fast table creation', only at the first invocation of * either of these the table DDL statements are issued. */ @Override public String getTableCreatorName() { return this.getClass().getSuperclass().getName(); } /* * Override Buyer table to change the field for buyer's description to use "Descrip", which will * cause issues on case sensitive databases if "Descrip" is not used within EclipseLink queries on case * sensitive databases. */ public TableDefinition buildBUYERTable() { TableDefinition table = new TableDefinition(); table.setName("CMP3_BUYER"); String[] unq1 = {"BUYER_ID", "BUYER_NAME"}; String[] unq2 = {"BUYER_ID", "Descrip"}; table.addUniqueKeyConstraint("UNQ_CMP3_BUYER_1", unq1); table.addUniqueKeyConstraint("UNQ_CMP3_BUYER_2", unq2); FieldDefinition field = new FieldDefinition(); field.setName("BUYER_ID"); field.setTypeName("NUMERIC"); field.setSize(15); field.setShouldAllowNull(false ); field.setIsPrimaryKey(true ); field.setUnique(false ); field.setIsIdentity(true ); table.addField(field); FieldDefinition field2 = new FieldDefinition(); field2.setName("BUYER_NAME"); field2.setTypeName("VARCHAR"); field2.setSize(30); field2.setShouldAllowNull(false); field2.setIsPrimaryKey(false ); field2.setUnique(false ); field2.setIsIdentity(false ); table.addField(field2); FieldDefinition fieldGender = new FieldDefinition(); fieldGender.setName("GENDER"); fieldGender.setTypeName("VARCHAR"); fieldGender.setSize(1); fieldGender.setShouldAllowNull(true); fieldGender.setIsPrimaryKey(false); fieldGender.setUnique(false); fieldGender.setIsIdentity(false); table.addField(fieldGender); FieldDefinition field3 = new FieldDefinition(); field3.setName("Descrip");//Intentionally mixed case. used to test strings passed in on case sensitive databases field3.setTypeName("VARCHAR"); field3.setSize(200); field3.setShouldAllowNull(false); field3.setIsPrimaryKey(false ); field3.setUnique(false ); field3.setIsIdentity(false ); table.addField(field3); FieldDefinition field4 = new FieldDefinition(); field4.setName("DTYPE"); field4.setTypeName("VARCHAR"); field4.setSize(200); field4.setShouldAllowNull(true ); field4.setIsPrimaryKey(false ); field4.setUnique(false ); field4.setIsIdentity(false ); table.addField(field4); FieldDefinition field5 = new FieldDefinition(); field5.setName("VERSION"); field5.setTypeName("NUMERIC"); field5.setSize(15); field5.setShouldAllowNull(true ); field5.setIsPrimaryKey(false ); field5.setUnique(false ); field5.setIsIdentity(false ); table.addField(field5); FieldDefinition fieldBUYINGDAYS = new FieldDefinition(); fieldBUYINGDAYS.setName("BUY_DAYS"); fieldBUYINGDAYS.setTypeName("LONG RAW"); fieldBUYINGDAYS.setSize(1000); fieldBUYINGDAYS.setSubSize(0); fieldBUYINGDAYS.setIsPrimaryKey(false); fieldBUYINGDAYS.setIsIdentity(false); fieldBUYINGDAYS.setUnique(false); fieldBUYINGDAYS.setShouldAllowNull(true); table.addField(fieldBUYINGDAYS); return table; } }