Author: steve.ebersole(a)jboss.com
Date: 2009-11-13 02:24:38 -0500 (Fri, 13 Nov 2009)
New Revision: 17970
Added:
sandbox/trunk/new-metadata/DESIGN.txt
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Attribute.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/AttributeContainer.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/BasicType.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Entity.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Type.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/TypeNature.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping/AttributeMapping.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractValueContainer.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Column.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/DerivedValue.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/InLineView.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ObjectName.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Table.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Value.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ValueContainer.java
sandbox/trunk/new-metadata/src/test/
sandbox/trunk/new-metadata/src/test/java/
sandbox/trunk/new-metadata/src/test/java/org/
sandbox/trunk/new-metadata/src/test/java/org/hibernate/
sandbox/trunk/new-metadata/src/test/java/org/hibernate/metadata/
sandbox/trunk/new-metadata/src/test/java/org/hibernate/metadata/schema/
sandbox/trunk/new-metadata/src/test/java/org/hibernate/metadata/schema/ObjectNameTests.java
Removed:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Nature.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping/DatatypeMapping.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractTable.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Column.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/DerivedColumn.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/LogicalTable.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/PhysicalColumn.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/PhysicalTable.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Table.java
Modified:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractColumn.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractColumnConstraint.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Constraint.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Datatype.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ForeignKey.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Index.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/PrimaryKey.java
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/UniqueKey.java
Log:
tad more work on this
Added: sandbox/trunk/new-metadata/DESIGN.txt
===================================================================
--- sandbox/trunk/new-metadata/DESIGN.txt (rev 0)
+++ sandbox/trunk/new-metadata/DESIGN.txt 2009-11-13 07:24:38 UTC (rev 17970)
@@ -0,0 +1,19 @@
+This file is intended as a list of the design goals for this work. What are we trying to
achieve? why? And
+how are we planning on going about it.
+
+Mainly this is to be a refactoring of the existing org.hibernate.mapping package. There
are two main problems with
+the current code:
+1) It represents a single unified view of the logical model which is neither the java
mode nor the
+database model; it is somewhere in between. Yet it does this in a singular manner.
+2) Lack of encapsulation
+
+To attempt to alleviate these problems, the proposal is a separation such that we have:
+1) Metadata about the database schema, in org.hibernate.metadata.schema package
+2) Metadata about the Java model, in the org.hibernate.metadata.java package. todo :
what about other entitymodes?
+3) Metadata about the mapping between the two above, in the
org.hibernate.metadata.mapping package
+
+Especially trying to keep them as independent as possible. Especially, the
+org.hibernate.metadata.schema and org.hibernate.metadata.java package should
+be independent onto themselves, with the org.hibernate.metadata.mapping package
+providing the linkage/binding
+
Added:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Attribute.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Attribute.java
(rev 0)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Attribute.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -0,0 +1,34 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.metadata.java;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public interface Attribute {
+ public String getName();
+ public AttributeContainer getAttributeContainer();
+}
Added:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/AttributeContainer.java
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/AttributeContainer.java
(rev 0)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/AttributeContainer.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -0,0 +1,37 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.metadata.java;
+
+import java.util.Set;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public interface AttributeContainer extends Type {
+ public Set getAttributes();
+
+ public Attribute getAttribute(String name);
+}
Added:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/BasicType.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/BasicType.java
(rev 0)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/BasicType.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -0,0 +1,45 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.metadata.java;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class BasicType implements Type {
+ private final Class javaType;
+
+ public BasicType(Class javaType) {
+ this.javaType = javaType;
+ }
+
+ public TypeNature getNature() {
+ return TypeNature.BASIC;
+ }
+
+ public Class getJavaType() {
+ return javaType;
+ }
+}
Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Entity.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Entity.java
(rev 0)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Entity.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -0,0 +1,32 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.metadata.java;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class Entity {
+}
Deleted: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Nature.java
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Nature.java 2009-11-13
04:27:35 UTC (rev 17969)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Nature.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -1,78 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
- * third-party contributors as indicated by either @author tags or express
- * copyright attribution statements applied by the authors. All
- * third-party contributions are distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.metadata.java;
-
-import java.io.Serializable;
-import java.util.HashMap;
-
-/**
- * Enumerations of the various types or natures of attributes.
- *
- * @author Steve Ebersole
- */
-public class Nature implements Serializable {
- private static final HashMap INSTANCES = new HashMap();
-
- public static final Nature VALUE = new Nature( "VALUE" );
- public static final Nature COMPONENT = new Nature( "COMPONENT" );
- public static final Nature ANY = new Nature( "ANY", true );
- public static final Nature ENTITY = new Nature( "ENTITY", true );
- public static final Nature COLLECTION = new Nature( "COLLECTION", true );
-
- static {
- INSTANCES.put( VALUE.name, VALUE );
- INSTANCES.put( COMPONENT.name, COMPONENT );
- INSTANCES.put( ANY.name, ANY );
- INSTANCES.put( ENTITY.name, ENTITY );
- INSTANCES.put( COLLECTION.name, COLLECTION );
- }
-
- private final String name;
- private final boolean association;
-
- private Nature(String name, boolean association) {
- this.name = name;
- this.association = association;
- }
-
- private Nature(String name) {
- this( name, false );
- }
-
- public String getName() {
- return name;
- }
-
- public boolean isAssociation() {
- return association;
- }
-
- public String toString() {
- return super.toString() + "[" + getName() + "]";
- }
-
- private Object readResolve() {
- return INSTANCES.get( name );
- }
-}
Added: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Type.java
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Type.java
(rev 0)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Type.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -0,0 +1,45 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.metadata.java;
+
+/**
+ * Basic information about a Java type, in regards to its role in particular set of
mappings.
+ *
+ * @author Steve Ebersole
+ */
+public interface Type {
+ /**
+ * Return the persistence type.
+ *
+ * @return persistence type
+ */
+ public TypeNature getNature();
+
+ /**
+ * Return the represented Java type.
+ *
+ * @return Java type
+ */
+ public Class getJavaType();
+}
Copied:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/TypeNature.java (from
rev 17967,
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/Nature.java)
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/TypeNature.java
(rev 0)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/java/TypeNature.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -0,0 +1,65 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.metadata.java;
+
+import java.io.Serializable;
+import java.util.HashMap;
+
+/**
+ * Describes the nature of a type.
+ *
+ * @author Steve Ebersole
+ */
+public class TypeNature implements Serializable {
+ public static final TypeNature BASIC = new TypeNature( "BASIC" );
+ public static final TypeNature COMPONENT = new TypeNature( "COMPONENT" );
+ public static final TypeNature ENTITY = new TypeNature( "ENTITY" );
+ public static final TypeNature SUPERCLASS = new TypeNature( "SUPERCLASS" );
+
+ private static final HashMap INSTANCES = new HashMap();
+ static {
+ INSTANCES.put( BASIC.name, BASIC );
+ INSTANCES.put( COMPONENT.name, COMPONENT );
+ INSTANCES.put( ENTITY.name, ENTITY );
+ INSTANCES.put( SUPERCLASS.name, SUPERCLASS );
+ }
+
+ private final String name;
+
+ private TypeNature(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String toString() {
+ return super.toString() + "[" + getName() + "]";
+ }
+
+ private Object readResolve() {
+ return INSTANCES.get( name );
+ }
+}
Copied:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping/AttributeMapping.java
(from rev 17967,
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping/DatatypeMapping.java)
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping/AttributeMapping.java
(rev 0)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping/AttributeMapping.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -0,0 +1,41 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.metadata.mapping;
+
+import org.hibernate.metadata.java.Attribute;
+import org.hibernate.metadata.schema.Value;
+
+/**
+ * Defines information about mapping an {@link Attribute attribute} to a set of one or
more database
+ * Represents the structural information pertaining to mapping between a Java type and an
SQL <tt>datatype</tt>.
+ *
+ * @author Steve Ebersole
+ */
+public interface AttributeMapping {
+ public Attribute getAttribute();
+
+ public Value[] getColumns();
+
+ // todo : type/transformation information...
+}
Deleted:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping/DatatypeMapping.java
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping/DatatypeMapping.java 2009-11-13
04:27:35 UTC (rev 17969)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/mapping/DatatypeMapping.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -1,47 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
- * third-party contributors as indicated by either @author tags or express
- * copyright attribution statements applied by the authors. All
- * third-party contributions are distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.metadata.mapping;
-
-import org.hibernate.metadata.schema.Datatype;
-
-/**
- * Represents the structural information pertaining to mapping between a Java type and an
SQL <tt>datatype</tt>.
- *
- * @author Steve Ebersole
- */
-public interface DatatypeMapping {
- /**
- * Retrieve the Java type described by this mapping.
- *
- * @return The Java class.
- */
- public Class getJavaType();
-
- /**
- * Retrieve the metadata about the contained SQL datatypes.
- *
- * @return The SQL datatype metadata.
- */
- public Datatype getSqlDatatypes();
-}
Modified:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractColumn.java
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractColumn.java 2009-11-13
04:27:35 UTC (rev 17969)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractColumn.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -23,22 +23,43 @@
*/
package org.hibernate.metadata.schema;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
- * Basic support for {@link Column} implementations.
+ * Basic support for {@link Value} implementations.
*
* @author Steve Ebersole
*/
-public abstract class AbstractColumn implements Column {
- private final Table table;
+public abstract class AbstractColumn implements Value {
+ private static final Logger log = LoggerFactory.getLogger( AbstractColumn.class );
- protected AbstractColumn(Table table) {
+ private final ValueContainer table;
+ private Datatype datatype;
+
+ protected AbstractColumn(ValueContainer table) {
this.table = table;
}
/**
* {@inheritDoc}
*/
- public Table getTable() {
+ public ValueContainer getTable() {
return table;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public Datatype getDatatype() {
+ return datatype;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setDatatype(Datatype datatype) {
+ log.debug( "setting datatype for column " + toDebugString() + " : "
+ datatype.getTypeCode() );
+ this.datatype = datatype;
+ }
}
Modified:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractColumnConstraint.java
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractColumnConstraint.java 2009-11-13
04:27:35 UTC (rev 17969)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractColumnConstraint.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -28,20 +28,22 @@
/**
* Support for contraints which specifically apply to a column or series of columns.
+ * <p/>
+ * todo : do we need to support defining these on particular schemas/catalogs?
*
* @author Steve Ebersole
*/
public abstract class AbstractColumnConstraint implements Constraint {
- private final Table table;
+ private final ValueContainer table;
private final String name;
- private List/*<Column>*/ columns = new ArrayList();
+ private List/*<Value>*/ columns = new ArrayList();
- protected AbstractColumnConstraint(Table table, String name) {
+ protected AbstractColumnConstraint(ValueContainer table, String name) {
this.table = table;
this.name = name;
}
- public Table getTable() {
+ public ValueContainer getTable() {
return table;
}
@@ -49,11 +51,14 @@
return name;
}
- public List/*<Column>*/ getColumns() {
+ public List/*<Value>*/ getColumns() {
return columns;
}
- public void addColumn(Column column) {
+ public void addColumn(Value column) {
+ if ( column.getTable() != getTable() ) {
+ throw new IllegalArgumentException( "Unable to add column to constraint; tables
did not match" );
+ }
columns.add( column );
}
}
Deleted:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractTable.java
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractTable.java 2009-11-13
04:27:35 UTC (rev 17969)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractTable.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -1,49 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
- * third-party contributors as indicated by either @author tags or express
- * copyright attribution statements applied by the authors. All
- * third-party contributions are distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.metadata.schema;
-
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-
-/**
- * TODO : javadoc
- *
- * @author Steve Ebersole
- */
-public abstract class AbstractTable implements Table {
- private PrimaryKey primaryKey = new PrimaryKey( this );
- private final LinkedHashSet columns = new LinkedHashSet();
-
- public void addColumn(Column column) {
- columns.add( column );
- }
-
- public PrimaryKey getPrimaryKey() {
- return primaryKey;
- }
-
- public Iterator iterateColumns() {
- return columns.iterator();
- }
-}
Copied:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractValueContainer.java
(from rev 17967,
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractTable.java)
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractValueContainer.java
(rev 0)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/AbstractValueContainer.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -0,0 +1,58 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.metadata.schema;
+
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+
+/**
+ * Convenience base class for implementing the {@link ValueContainer} contract
+ *
+ * @author Steve Ebersole
+ */
+public abstract class AbstractValueContainer implements ValueContainer {
+ private PrimaryKey primaryKey = new PrimaryKey( this );
+ private final LinkedHashSet values = new LinkedHashSet();
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addValue(Value value) {
+ values.add( value );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Iterator iterateValues() {
+ return values.iterator();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public PrimaryKey getPrimaryKey() {
+ return primaryKey;
+ }
+}
Deleted:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Column.java
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Column.java 2009-11-13
04:27:35 UTC (rev 17969)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Column.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -1,40 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
- * third-party contributors as indicated by either @author tags or express
- * copyright attribution statements applied by the authors. All
- * third-party contributions are distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.metadata.schema;
-
-/**
- * Models a column within a {@link Table}.
- *
- * @author Steve Ebersole
- */
-public interface Column {
- /**
- * Retrieve the table that owns this column.
- *
- * @return The owning table.
- */
- public Table getTable();
-
- public String toDebugString();
-}
Copied: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Column.java
(from rev 17967,
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/PhysicalColumn.java)
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Column.java
(rev 0)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Column.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -0,0 +1,49 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.metadata.schema;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class Column extends AbstractColumn implements Value {
+ private final String name;
+
+ protected Column(ValueContainer table, String name) {
+ super( table );
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toDebugString() {
+ return getTable().toDebugString() + '.' + getName();
+ }
+}
Modified:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Constraint.java
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Constraint.java 2009-11-13
04:27:35 UTC (rev 17969)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Constraint.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -35,8 +35,8 @@
* @author Steve Ebersole
*/
public interface Constraint {
- public Table getTable();
+ public ValueContainer getTable();
public String getName();
- public List/*<Column>*/ getColumns();
+ public List/*<Value>*/ getColumns();
}
Modified:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Datatype.java
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Datatype.java 2009-11-13
04:27:35 UTC (rev 17969)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Datatype.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -24,7 +24,9 @@
package org.hibernate.metadata.schema;
/**
- * Models a SQL DATATYPE.
+ * Models a JDBC {@link java.sql.Types DATATYPE}
+ * </p>
+ * todo : should we model scale and precision here or on Value?
*
* @author Steve Ebersole
*/
Deleted:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/DerivedColumn.java
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/DerivedColumn.java 2009-11-13
04:27:35 UTC (rev 17969)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/DerivedColumn.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -1,42 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
- * third-party contributors as indicated by either @author tags or express
- * copyright attribution statements applied by the authors. All
- * third-party contributions are distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.metadata.schema;
-
-/**
- * A derived column is the result of a <tt>formula</tt> mapping.
- *
- * @author Steve Ebersole
- */
-public class DerivedColumn extends AbstractColumn implements Column {
- public DerivedColumn(Table table) {
- super( table );
- }
-
- /**
- * {@inheritDoc}
- */
- public String toDebugString() {
- return getTable().toDebugString() + ".{derived-column}";
- }
-}
Copied:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/DerivedValue.java
(from rev 17967,
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/DerivedColumn.java)
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/DerivedValue.java
(rev 0)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/DerivedValue.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -0,0 +1,42 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.metadata.schema;
+
+/**
+ * A derived column is the result of a <tt>formula</tt> mapping.
+ *
+ * @author Steve Ebersole
+ */
+public class DerivedValue extends AbstractColumn implements Value {
+ public DerivedValue(ValueContainer table) {
+ super( table );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toDebugString() {
+ return getTable().toDebugString() + ".{derived-column}";
+ }
+}
Modified:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ForeignKey.java
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ForeignKey.java 2009-11-13
04:27:35 UTC (rev 17969)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ForeignKey.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -37,20 +37,20 @@
public class ForeignKey implements Constraint {
private static final Logger log = LoggerFactory.getLogger( ForeignKey.class );
- private final Table sourceTable;
- private final Table targetTable;
+ private final ValueContainer sourceTable;
+ private final ValueContainer targetTable;
private final String name;
- private List/*<Column>*/ sourceColumns = new ArrayList();
- private List/*<Column>*/ targetColumns;
+ private List/*<Value>*/ sourceColumns = new ArrayList();
+ private List/*<Value>*/ targetColumns;
- public ForeignKey(Table sourceTable, Table targetTable, String name) {
+ public ForeignKey(ValueContainer sourceTable, ValueContainer targetTable, String name)
{
this.sourceTable = sourceTable;
this.targetTable = targetTable;
this.name = name;
}
- public ForeignKey(Table sourceTable, Table targetTable) {
+ public ForeignKey(ValueContainer sourceTable, ValueContainer targetTable) {
this( sourceTable, targetTable, null );
}
@@ -58,19 +58,19 @@
return name;
}
- public Table getTable() {
+ public ValueContainer getTable() {
return getSourceTable();
}
- public Table getSourceTable() {
+ public ValueContainer getSourceTable() {
return sourceTable;
}
- public Table getTargetTable() {
+ public ValueContainer getTargetTable() {
return targetTable;
}
- public List/*<Column>*/ getColumns() {
+ public List/*<Value>*/ getColumns() {
return getSourceColumns();
}
@@ -84,7 +84,7 @@
: targetColumns;
}
- public void addColumnMapping(Column sourceColumn, Column targetColumn) {
+ public void addColumnMapping(Value sourceColumn, Value targetColumn) {
if ( targetColumn == null ) {
if ( targetColumns != null ) {
if ( log.isWarnEnabled() ) {
@@ -100,7 +100,7 @@
if ( targetColumns == null ) {
if ( !sourceColumns.isEmpty() ) {
log.warn(
- "Column mapping mismatch as part of FK [table=" +
getTable().toDebugString()
+ "Value mapping mismatch as part of FK [table=" +
getTable().toDebugString()
+ ", name=" + getName() + "] while adding source column ["
+ sourceColumn.toDebugString() + "]"
);
Copied:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/InLineView.java
(from rev 17967,
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/LogicalTable.java)
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/InLineView.java
(rev 0)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/InLineView.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -0,0 +1,67 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.metadata.schema;
+
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * A <tt>data container</tt> defined by a <tt>SELECT</tt>
statement. This translates into an inline view in the
+ * SQL statements: <code>select ... from (select ... from logical_table_table ...)
...</code>
+ *
+ * @author Steve Ebersole
+ */
+public class InLineView extends AbstractValueContainer implements ValueContainer {
+ private final String select;
+ private final String uniqueValueQualifier;
+ private Set synchronizedTableSpaces = java.util.Collections.EMPTY_SET;
+
+ public InLineView(String select, String uniqueValueQualifier) {
+ this.select = select;
+ this.uniqueValueQualifier = uniqueValueQualifier;
+ }
+
+ public String getSelect() {
+ return select;
+ }
+
+ public String getUniqueValueQualifier() {
+ return uniqueValueQualifier;
+ }
+
+ public void addSynchronizedTableSpace(String space) {
+ if ( synchronizedTableSpaces == java.util.Collections.EMPTY_SET ) {
+ synchronizedTableSpaces = new HashSet();
+ }
+ synchronizedTableSpaces.add( space );
+ }
+
+ public Set getSpaces() {
+ return synchronizedTableSpaces;
+ }
+
+ public String toDebugString() {
+ return "{inline-view}";
+ }
+}
Modified:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Index.java
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Index.java 2009-11-13
04:27:35 UTC (rev 17969)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Index.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -29,7 +29,7 @@
* @author Steve Ebersole
*/
public class Index extends AbstractColumnConstraint implements Constraint {
- protected Index(Table table, String name) {
+ protected Index(ValueContainer table, String name) {
super( table, name );
}
}
Deleted:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/LogicalTable.java
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/LogicalTable.java 2009-11-13
04:27:35 UTC (rev 17969)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/LogicalTable.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -1,57 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
- * third-party contributors as indicated by either @author tags or express
- * copyright attribution statements applied by the authors. All
- * third-party contributions are distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.metadata.schema;
-
-import java.util.Set;
-import java.util.HashSet;
-
-/**
- * A <tt>data container</tt> defined by a <tt>SELECT</tt>
statement. This translates into an inline view in the
- * SQL statements: <code>select ... from (select ... from logical_table_table ...)
...</code>
- *
- * @author Steve Ebersole
- */
-public class LogicalTable extends AbstractTable implements Table {
- private final String select;
- private Set synchronizedTableSpaces = java.util.Collections.EMPTY_SET;
-
- public LogicalTable(String select) {
- this.select = select;
- }
-
- public void addSynchronizedTableSpace(String space) {
- if ( synchronizedTableSpaces == java.util.Collections.EMPTY_SET ) {
- synchronizedTableSpaces = new HashSet();
- }
- synchronizedTableSpaces.add( space );
- }
-
- public Set getSpaces() {
- return synchronizedTableSpaces;
- }
-
- public String toDebugString() {
- return "{inline-view}";
- }
-}
Added:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ObjectName.java
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ObjectName.java
(rev 0)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ObjectName.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -0,0 +1,125 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.metadata.schema;
+
+/**
+ * Models the qualified name of a database object.
+ *
+ * @author Steve Ebersole
+ */
+public class ObjectName {
+ private final String name;
+ private final String schema;
+ private final String catalog;
+ private final String identifier;
+ private final int hashCode;
+
+ /**
+ * Creates a qualified name reference.
+ *
+ * @param schema The in which the object is defined (optional)
+ * @param catalog The catalog in which the object is defined (optional)
+ * @param name The name (required)
+ */
+ public ObjectName(String schema, String catalog, String name) {
+ if ( name == null || name.trim().length() == 0 ) {
+ throw new IllegalArgumentException( "Object name must be specified" );
+ }
+ this.name = name;
+ this.schema = schema;
+ this.catalog = catalog;
+
+ StringBuffer buff = new StringBuffer( name );
+ if ( catalog != null ) {
+ buff.insert( 0, catalog + '.' );
+ }
+ if ( schema != null ) {
+ buff.insert( 0, schema + '.' );
+ }
+ this.identifier = buff.toString();
+
+ int tmpHashCode = schema != null ? schema.hashCode() : 0;
+ tmpHashCode = 31 * tmpHashCode + (catalog != null ? catalog.hashCode() : 0);
+ tmpHashCode = 31 * tmpHashCode + name.hashCode();
+ this.hashCode = tmpHashCode;
+ }
+
+ public String getSchema() {
+ return schema;
+ }
+
+ public String getCatalog() {
+ return catalog;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ ObjectName that = (ObjectName) o;
+
+ return name.equals( that.name )
+ && areEqual( catalog, that.catalog )
+ && areEqual( schema, that.schema );
+ }
+
+ private boolean areEqual(String one, String other) {
+ return one == null
+ ? other == null
+ : one.equals( other );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int hashCode() {
+ return hashCode;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString() {
+ return "ObjectName{" +
+ "name='" + name + '\'' +
+ ", schema='" + schema + '\'' +
+ ", catalog='" + catalog + '\'' +
+ '}';
+ }
+}
Deleted:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/PhysicalColumn.java
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/PhysicalColumn.java 2009-11-13
04:27:35 UTC (rev 17969)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/PhysicalColumn.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -1,46 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
- * third-party contributors as indicated by either @author tags or express
- * copyright attribution statements applied by the authors. All
- * third-party contributions are distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.metadata.schema;
-
-/**
- * TODO : javadoc
- *
- * @author Steve Ebersole
- */
-public class PhysicalColumn extends AbstractColumn implements Column {
- private final String name;
-
- protected PhysicalColumn(Table table, String name) {
- super( table );
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public String toDebugString() {
- return getTable().toDebugString() + '.' + getName();
- }
-}
Deleted:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/PhysicalTable.java
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/PhysicalTable.java 2009-11-13
04:27:35 UTC (rev 17969)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/PhysicalTable.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -1,58 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
- * third-party contributors as indicated by either @author tags or express
- * copyright attribution statements applied by the authors. All
- * third-party contributions are distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.metadata.schema;
-
-import java.util.Set;
-
-/**
- * Models the concept of a relational <tt>TABLE</tt> (or
<tt>VIEW</tt>) database to which we map information.
- *
- * @author Gavin King
- * @author Steve Ebersole
- */
-public class PhysicalTable extends AbstractTable implements Table, Exportable {
- private final String explicitSchema;
- private final String explicitCatalog;
- private final String name;
- private final Set spaces;
-
- public PhysicalTable(String explicitSchema, String explicitCatalog, String name) {
- this.explicitSchema = explicitSchema;
- this.explicitCatalog = explicitCatalog;
- this.name = name;
- this.spaces = java.util.Collections.singleton( name );
- }
-
- public String getExportIdentifier() {
- return name;
- }
-
- public Set getSpaces() {
- return spaces;
- }
-
- public String toDebugString() {
- return name;
- }
-}
Modified:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/PrimaryKey.java
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/PrimaryKey.java 2009-11-13
04:27:35 UTC (rev 17969)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/PrimaryKey.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -39,7 +39,7 @@
// later in terms of building the metamodel
private String name;
- public PrimaryKey(Table table) {
+ public PrimaryKey(ValueContainer table) {
super( table, null );
}
Deleted:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Table.java
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Table.java 2009-11-13
04:27:35 UTC (rev 17969)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Table.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -1,44 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
- * third-party contributors as indicated by either @author tags or express
- * copyright attribution statements applied by the authors. All
- * third-party contributions are distributed under license by Red Hat Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
- */
-package org.hibernate.metadata.schema;
-
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * Contract for data containers (what the ANSI SQL spec calls "table
specifications") to which we can map
- * entity state.
- *
- * @author Steve Ebersole
- */
-public interface Table {
- public PrimaryKey getPrimaryKey();
-
- public void addColumn(Column column);
-
- public Iterator iterateColumns();
- public Set getSpaces();
-
- public String toDebugString();
-}
Copied: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Table.java
(from rev 17967,
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/PhysicalTable.java)
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Table.java
(rev 0)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Table.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -0,0 +1,83 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.metadata.schema;
+
+import java.util.Set;
+
+/**
+ * Models the concept of a relational <tt>TABLE</tt> (or
<tt>VIEW</tt>).
+ *
+ * @author Gavin King
+ * @author Steve Ebersole
+ */
+public class Table extends AbstractValueContainer implements ValueContainer, Exportable
{
+ private final ObjectName name;
+ private final Set spaces;
+
+ public Table(ObjectName name) {
+ this.name = name;
+ this.spaces = java.util.Collections.singleton( name );
+ }
+
+ public ObjectName getObjectName() {
+ return name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getUniqueValueQualifier() {
+ return getObjectName().getIdentifier();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getExportIdentifier() {
+ return getObjectName().getIdentifier();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set getSpaces() {
+ return spaces;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toDebugString() {
+ return getObjectName().getIdentifier();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString() {
+ return "Table{" +
+ "name=" + getObjectName().getIdentifier() +
+ '}';
+ }
+}
Modified:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/UniqueKey.java
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/UniqueKey.java 2009-11-13
04:27:35 UTC (rev 17969)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/UniqueKey.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -29,7 +29,7 @@
* @author Steve Ebersole
*/
public class UniqueKey extends AbstractColumnConstraint implements Constraint {
- protected UniqueKey(Table table, String name) {
+ protected UniqueKey(ValueContainer table, String name) {
super( table, name );
}
}
Copied: sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Value.java
(from rev 17967,
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Column.java)
===================================================================
--- sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Value.java
(rev 0)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Value.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -0,0 +1,55 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.metadata.schema;
+
+/**
+ * Models a value within a {@link ValueContainer}. This will generally be either a
+ * {@link Column column} or a {@link DerivedValue derived value}.
+ *
+ * @author Steve Ebersole
+ */
+public interface Value {
+ /**
+ * Retrieve the table that owns this value.
+ *
+ * @return The owning table.
+ */
+ public ValueContainer getTable();
+
+ /**
+ * Retrieve the datatype of this value.
+ *
+ * @return The value's datatype
+ */
+ public Datatype getDatatype();
+
+ /**
+ * Set the datatype of this value.
+ *
+ * @param datatype
+ */
+ public void setDatatype(Datatype datatype);
+
+ public String toDebugString();
+}
Copied:
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ValueContainer.java
(from rev 17967,
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/Table.java)
===================================================================
---
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ValueContainer.java
(rev 0)
+++
sandbox/trunk/new-metadata/src/main/java/org/hibernate/metadata/schema/ValueContainer.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -0,0 +1,68 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.metadata.schema;
+
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * Contract for data containers (what the ANSI SQL spec calls "table
specifications") to which we can map
+ * entity state. The two flavors here are {@link Table physical table} and {@link
InLineView inline view}.
+ *
+ * @author Steve Ebersole
+ */
+public interface ValueContainer {
+ /**
+ * Get the primary key definition for this container.
+ *
+ * @return The PK definition.
+ */
+ public PrimaryKey getPrimaryKey();
+
+ /**
+ * Adds a value definition to the container.
+ *
+ * @param value The value definition
+ */
+ public void addValue(Value value);
+
+ /**
+ * Obtain an iterator over this containers current set of value definitions.
+ *
+ * @return Iterator over value definitions.
+ */
+ public Iterator iterateValues();
+
+ public Set getSpaces();
+
+ /**
+ * Get a unique identifier which can be used to qualify {@link Value values} belonging
to
+ * this container. Intended for use in logging.
+ *
+ * @return The qualifier
+ */
+ public String getUniqueValueQualifier();
+
+ public String toDebugString();
+}
Added:
sandbox/trunk/new-metadata/src/test/java/org/hibernate/metadata/schema/ObjectNameTests.java
===================================================================
---
sandbox/trunk/new-metadata/src/test/java/org/hibernate/metadata/schema/ObjectNameTests.java
(rev 0)
+++
sandbox/trunk/new-metadata/src/test/java/org/hibernate/metadata/schema/ObjectNameTests.java 2009-11-13
07:24:38 UTC (rev 17970)
@@ -0,0 +1,54 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009 by Red Hat Inc and/or its affiliates or by
+ * third-party contributors as indicated by either @author tags or express
+ * copyright attribution statements applied by the authors. All
+ * third-party contributions are distributed under license by Red Hat Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
+package org.hibernate.metadata.schema;
+
+import junit.framework.TestCase;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class ObjectNameTests extends TestCase {
+ public void testMissingName() {
+ try {
+ new ObjectName( null, null, null );
+ fail();
+ }
+ catch ( IllegalArgumentException ignore ) {
+ }
+
+ try {
+ new ObjectName( "schema", "catalog", null );
+ fail();
+ }
+ catch ( IllegalArgumentException ignore ) {
+ }
+ }
+
+ public void testIdentifierBuilding() {
+ ObjectName on = new ObjectName( "schema", "catalog",
"name" );
+ assertEquals( "schema.catalog.name", on.getIdentifier() );
+ }
+}