public void createTables(DatabaseSession session) { dropTableConstraints(session); new InheritanceTableCreator().replaceTables(session); SchemaManager schemaManager = new SchemaManager(session); if (session.getLogin().getPlatform().isOracle()) { schemaManager.replaceObject(Computer.oracleView()); schemaManager.replaceObject(Vehicle.oracleView()); } else if (session.getLogin().getPlatform().isSybase()) { schemaManager.replaceObject(Computer.sybaseView()); schemaManager.replaceObject(Vehicle.sybaseView()); // CREATE VIEW statement was added in MySQL 5.0.1. Uncomment it when we support MySQL 5 // } else if (session.getLogin().getPlatform().isMySQL()) { // schemaManager.replaceObject(Computer.sybaseView()); // schemaManager.replaceObject(Vehicle.mySQLView()); } }
public void addDescriptors(DatabaseSession session) { // Oracle has bug in outjoins that require outerjoin of inheritance type. // This should really be handled by the platform during expression normalization... // Id for Entomologist can be negative (millis cast to int wraps...) project.getDescriptor(Entomologist.class).setIdValidation(IdValidation.NONE); session.addDescriptors(project); // For using read all subclasses views. DatabasePlatform platform = session.getLogin().getPlatform(); if (platform.isOracle() || platform.isSybase()) { ClassDescriptor computerDescriptor = session.getDescriptor(Computer.class); ClassDescriptor vehicleDescriptor = session.getDescriptor(Vehicle.class); computerDescriptor.getInheritancePolicy().setReadAllSubclassesViewName("AllComputers"); vehicleDescriptor.getInheritancePolicy().setReadAllSubclassesViewName("AllVehicles"); } // Enable outer-join on AnimalMatt hierarchy. session .getDescriptor(Animal_Matt.class) .getInheritancePolicy() .setShouldOuterJoinSubclasses(true); }