Author: vyemialyanchyk
Date: 2010-03-29 11:58:02 -0400 (Mon, 29 Mar 2010)
New Revision: 21117
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/.classpath
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/.cvsignore
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/.project
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/META-INF/
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/META-INF/MANIFEST.MF
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/about.html
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/about.ini
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/about.mappings
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/about.properties
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/build.properties
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/hibernate_icon.gif
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/annotations/
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/annotations/ejb3-persistence.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/annotations/hibernate-annotations.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/annotations/hibernate-commons-annotations.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/annotations/hibernate-entitymanager.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/annotations/hibernate-validator.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/bsh-core-2.0b4.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/antlr-2.7.6.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/asm-attrs.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/asm.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/c3p0-0.9.1.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/cglib-2.2.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/commons-collections-3.1.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/commons-logging-1.0.4.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/concurrent-1.3.2.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/connector.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/dom4j-1.6.1.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/ehcache-1.2.3.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/hibernate-jmx.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/hibernate3.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jaas.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/javassist.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jboss-cache.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jboss-common.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jboss-jmx.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jboss-system.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jdbc2_0-stdext.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jgroups-2.2.8.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jta.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/log4j-1.2.15.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/oscache-2.1.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/proxool-0.8.3.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/slf4j-api-1.5.8.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/slf4j-log4j12-1.5.8.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/swarmcache-1.0rc2.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/tools/
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/tools/freemarker.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/tools/hibernate-tools.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/tools/jtidy-r8-20060801.jar
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/plugin.properties
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/ConsoleConfigClassLoader.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/ConsoleQueryParameter.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/FakeDelegatingDriver.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/FakeTransactionManagerLookup.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/MediatorPlugin.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/Messages.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/Messages.properties
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/QueryInputModel.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/execution/
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/execution/DefaultExecutionContext.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/execution/ExecutionContext.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/execution/ExecutionContextHolder.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/logging/
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/logging/CurrentContext.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/preferences/
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/preferences/ConsoleConfigurationPreferences.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/AbstractTypeStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/AnyStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ArrayStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ArtifactCollectorStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/BagStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/Cfg2HbmToolStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ClassMetadataStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/CollectionMetadataStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/CollectionStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/CollectionTypeStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ColumnStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ComponentStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ConfigurationStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ConfigurationStubFactory.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ConfigurationStubJDBCMetaData.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ConnectionProviderStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/DefaultDatabaseCollectorStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/DefaultReverseEngineeringStrategyStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/DependantValueStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/DialectStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/EntityModeStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/EntityTypeStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/EnumTypeStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/EnvironmentStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ExporterStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/FetchModeStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ForeignKeyStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/GenericExporterStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HQLCompletionProposalStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateConfigurationExporterStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateConsoleRuntimeException.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateMappingExporterStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateMappingGlobalSettingsStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HqlSqlTokenTypesStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IHQLCodeAssistStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IHQLCompletionRequestorStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IdentifierBagStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IdentifierCollectionStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ImmutableTypeStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IndexedCollectionStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IntegerTypeStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JDBCReaderStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JDBCToHibernateTypeHelperStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JoinStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JoinedSubclassStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/KeyValueStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ListStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ManyToOneStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/MapStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/MappingStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/MappingsStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/NamingStrategyStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/NullableTypeStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/OneToManyStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/OneToOneStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/OverrideRepositoryStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/POJOClassStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PersistentClassStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PersistentClassStubFactory.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PrimaryKeyStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PrimitiveArrayStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PrimitiveTypeStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ProgressListenerStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PropertyStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ReverseEngineeringSettingsStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ReverseEngineeringStrategyStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/RootClassStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SQLTypeMappingStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SessionStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SessionStubFactory.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SetStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SettingsStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SimpleValueStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SingleTableSubclassStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SubclassStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TableFilterStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TableIdentifierStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TableStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ToOneStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TypeStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TypeStubFactory.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ValueStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ValueStubFactory.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ValueVisitorStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/XMLPrettyPrinterStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/tools/
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/CollectionHelper.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/HqlBaseLexerStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/OpenMappingUtilsEjb3.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/ParserHelper.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/ReflectHelper.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/StringHelper.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/XMLHelper.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/util/
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/util/CollectionPropertySource.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/util/ELTransformer.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/util/Formatter.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/util/QLFormatHelper.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-6070 - update
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/.classpath
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/.classpath
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/.classpath 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="lib" path="lib/hibernate/asm.jar"/>
+ <classpathentry kind="lib"
path="lib/hibernate/asm-attrs.jar"/>
+ <classpathentry exported="true" kind="lib"
path="lib/hibernate/dom4j-1.6.1.jar"/>
+ <classpathentry kind="lib"
path="lib/hibernate/jboss-cache.jar"/>
+ <classpathentry kind="lib"
path="lib/hibernate/jboss-common.jar"/>
+ <classpathentry kind="lib"
path="lib/hibernate/jboss-jmx.jar"/>
+ <classpathentry kind="lib"
path="lib/hibernate/jboss-system.jar"/>
+ <classpathentry kind="lib"
path="lib/hibernate/jdbc2_0-stdext.jar"/>
+ <classpathentry kind="lib" path="lib/hibernate/jta.jar"/>
+ <classpathentry kind="lib" path="lib/hibernate/jaas.jar"/>
+ <classpathentry kind="lib"
path="lib/hibernate/oscache-2.1.jar"/>
+ <classpathentry kind="lib"
path="lib/hibernate/proxool-0.8.3.jar"/>
+ <classpathentry kind="lib"
path="lib/hibernate/swarmcache-1.0rc2.jar"/>
+ <classpathentry kind="lib"
path="lib/annotations/hibernate-annotations.jar"
sourcepath="D:/Temp/_hibernate/hibernate-annotations-3.4.0.GA-sources.jar
"/>
+ <classpathentry kind="lib"
path="lib/hibernate/jgroups-2.2.8.jar"/>
+ <classpathentry kind="lib"
path="lib/hibernate/antlr-2.7.6.jar"/>
+ <classpathentry kind="lib"
path="lib/annotations/hibernate-entitymanager.jar"
sourcepath="D:/Temp/_hibernate/hibernate-entitymanager-3.4.0.GA-sources.jar"/>
+ <classpathentry kind="lib"
path="lib/hibernate/javassist.jar"/>
+ <classpathentry kind="lib"
path="lib/annotations/hibernate-validator.jar"/>
+ <classpathentry exported="true" kind="lib"
path="lib/hibernate/log4j-1.2.15.jar"/>
+ <classpathentry kind="lib" path="lib/hibernate/hibernate-jmx.jar"
sourcepath="D:/Temp/_hibernate/hibernate-jmx-3.3.2.GA-sources.jar "/>
+ <classpathentry kind="lib"
path="lib/hibernate/commons-collections-3.1.jar"/>
+ <classpathentry kind="lib"
path="lib/hibernate/slf4j-api-1.5.8.jar"
sourcepath="D:/Temp/_hibernate/slf4j-api-1.5.8-sources.jar"/>
+ <classpathentry exported="true" kind="lib"
path="lib/hibernate/cglib-2.2.jar"
sourcepath="D:/Temp/_hibernate/cglib-src-2.2.jar"/>
+ <classpathentry kind="lib"
path="lib/annotations/hibernate-commons-annotations.jar"
sourcepath="D:/Temp/_hibernate/hibernate-commons-annotations-3.1.0.GA-sources.jar
"/>
+ <classpathentry kind="lib"
path="lib/annotations/ejb3-persistence.jar"/>
+ <classpathentry kind="lib"
path="lib/hibernate/c3p0-0.9.1.jar"/>
+ <classpathentry exported="true" kind="lib"
path="lib/hibernate/commons-logging-1.0.4.jar"/>
+ <classpathentry kind="lib"
path="lib/hibernate/concurrent-1.3.2.jar"/>
+ <classpathentry kind="lib"
path="lib/hibernate/connector.jar"/>
+ <classpathentry kind="lib"
path="lib/hibernate/ehcache-1.2.3.jar"/>
+ <classpathentry kind="lib"
path="lib/hibernate/slf4j-log4j12-1.5.8.jar"/>
+ <classpathentry kind="lib" path="lib/tools/freemarker.jar"/>
+ <classpathentry kind="lib" path="lib/tools/hibernate-tools.jar"
sourcepath="C:/RHDS/hibernate/branches/Branch_3_2/HibernateExt_without_changes"/>
+ <classpathentry kind="lib"
path="lib/tools/jtidy-r8-20060801.jar"/>
+ <classpathentry kind="lib" path="lib/hibernate/hibernate3.jar"
sourcepath="D:/Temp/_hibernate/hibernate-core-3.3.2.GA-sources.jar "/>
+ <classpathentry kind="lib" path="lib/bsh-core-2.0b4.jar"/>
+ <classpathentry kind="output" path="build/eclipse"/>
+</classpath>
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/.cvsignore
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/.cvsignore
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/.cvsignore 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,2 @@
+build
+.settings
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/.project
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/.project
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/.project 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.hibernate.mediator</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/META-INF/MANIFEST.MF
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/META-INF/MANIFEST.MF
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/META-INF/MANIFEST.MF 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,75 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name.0
+Bundle-SymbolicName: org.hibernate.mediator;singleton:=true
+Bundle-Version: 3.3.0.qualifier
+Bundle-ClassPath: org.hibernate.mediator.jar,
+ lib/hibernate/asm.jar,
+ lib/hibernate/asm-attrs.jar,
+ lib/hibernate/commons-collections-2.1.1.jar,
+ lib/hibernate/commons-logging-1.0.4.jar,
+ lib/hibernate/concurrent-1.3.2.jar,
+ lib/hibernate/connector.jar,
+ lib/hibernate/dom4j-1.6.1.jar,
+ lib/hibernate/hibernate3.jar,
+ lib/hibernate/jboss-cache.jar,
+ lib/hibernate/jboss-common.jar,
+ lib/hibernate/jboss-jmx.jar,
+ lib/hibernate/jboss-system.jar,
+ lib/hibernate/jdbc2_0-stdext.jar,
+ lib/hibernate/jta.jar,
+ lib/hibernate/jaas.jar,
+ lib/hibernate/oscache-2.1.jar,
+ lib/hibernate/proxool-0.8.3.jar,
+ lib/hibernate/swarmcache-1.0rc2.jar,
+ lib/tools/hibernate-tools.jar,
+ lib/tools/bsh-2.0b1.jar,
+ lib/tools/freemarker.jar,
+ lib/bsh-core-2.0b4.jar,
+ lib/annotations/ejb3-persistence.jar,
+ lib/annotations/hibernate-annotations.jar,
+ lib/hibernate/cglib-2.1.3.jar,
+ lib/hibernate/jgroups-2.2.8.jar,
+ lib/hibernate/antlr-2.7.6.jar,
+ lib/tools/jtidy-r8-20060801.jar,
+ lib/annotations/hibernate-entitymanager.jar,
+ lib/hibernate/javassist.jar,
+ lib/hibernate/ehcache-1.2.3.jar,
+ lib/hibernate/c3p0-0.9.1.jar,
+ lib/annotations/hibernate-commons-annotations.jar,
+ lib/annotations/hibernate-validator.jar,
+ lib/annotations/hibernate-search.jar,
+ lib/annotations/lucene-core-2.2.0.jar,
+ lib/hibernate/log4j-1.2.15.jar,
+ lib/hibernate/cglib-2.2.jar,
+ lib/hibernate/commons-collections-3.1.jar,
+ lib/hibernate/hibernate-jmx.jar,
+ lib/hibernate/slf4j-api-1.5.8.jar,
+ lib/hibernate/slf4j-log4j12-1.5.8.jar
+Bundle-Vendor: %Bundle-Vendor.0
+Bundle-Localization: plugin
+Export-Package: org.hibernate.mediator,
+ org.hibernate.mediator.execution,
+ org.hibernate.mediator.logging,
+ org.hibernate.mediator.preferences,
+ org.hibernate.mediator.stubs,
+ org.hibernate.mediator.stubs.util,
+ org.hibernate.mediator.util,
+ org.apache.log4j,
+ org.apache.log4j.helpers,
+ org.apache.log4j.spi,
+ org.apache.commons.logging,
+ org.dom4j,
+ org.dom4j.io,
+ net.sf.cglib.core,
+ net.sf.cglib.proxy,
+ net.sf.cglib.reflect
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.ui.console,
+ org.eclipse.ui.views,
+ org.eclipse.jface,
+ org.eclipse.jdt.apt.core,
+ org.eclipse.datatools.connectivity
+Bundle-ActivationPolicy: lazy
+Eclipse-BuddyPolicy: registered
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/about.html
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/about.html
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/about.html 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1" />
+<title>Hibernate Tools</title>
+<style type="text/css" media="screen">
+<!--
+ body {
+ font-family: Sans-serif, Arial, Helvetica;
+ }
+
+-->
+</style>
+</head>
+<body>
+<h1>Hibernate Tools</h1>
+
+<p>
+This plugin is part of the Hibernate Tools developed by the <a
href="http://www.hibernate.org">Hibernate Team</a> and <a
href="http://www.jboss.com">JBoss Inc.</a>
+</p>
+
+<p>Information about this plugin is available at <a
href="http://tools.hibernate.org">tools.hibernate.org</a>
+and <a
href="http://www.jboss.org/tools">JBoss Tools project
page</a></p>
+
+<p>
+This software is distributed under the terms of the FSF Lesser Gnu
+Public License (see <a
href="http://www.gnu.org/copyleft/lesser.txt">LGPL</a>).
+</p>
+</body>
+</html>
\ No newline at end of file
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/about.ini
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/about.ini
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/about.ini 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,27 @@
+# about.ini
+# contains information about a feature
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# "%key" are externalized strings defined in about.properties
+# This file does not need to be translated.
+# test
+# Property "aboutText" contains blurb for "About" dialog
(translated)
+aboutText=%blurb
+
+# Property "windowImage" contains path to window icon (16x16)
+# needed for primary features only
+
+# Property "featureImage" contains path to feature image (32x32)
+featureImage=hibernate_icon.gif
+
+# Property "aboutImage" contains path to product image (500x330 or 115x164)
+# needed for primary features only
+
+# Property "appName" contains name of the application (not translated)
+# needed for primary features only
+
+# Property "welcomePerspective" contains the id of the perspective in which
the
+# welcome page is to be opened.
+# optional
+
+
+
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/about.mappings
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/about.mappings
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/about.mappings 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,5 @@
+# about.mappings
+# contains fill-ins for about.properties
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file does not need to be translated.
+
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/about.properties
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/about.properties
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/about.properties 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,2 @@
+blurb=Hibernate Tools for Eclipse\n\nVersion\: {featureVersion}\n\n(c) Copyright JBoss by
Red Hat, contributors and others 2004 - 2010. All rights reserved.\nVisit
http\://tools.hibernate.org
+
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/build.properties
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/build.properties
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/build.properties 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,30 @@
+bin.includes = plugin.xml,\
+ org.hibernate.mediator.jar,\
+ lib/,\
+ META-INF/,\
+ hibernate-log4j.properties,\
+ about.html,\
+ lib/tools/jtidy-r8-20060801.jar,\
+ lib/annotations/hibernate-entitymanager.jar,\
+ lib/hibernate/javassist.jar,\
+ lib/hibernate/ehcache-1.2.3.jar,\
+ lib/hibernate/c3p0-0.9.1.jar,\
+ lib/annotations/hibernate-commons-annotations.jar,\
+ lib/annotations/hibernate-validator.jar,\
+ lib/hibernate/log4j-1.2.15.jar,\
+ lib/hibernate/slf4j-api-1.5.8.jar,\
+ lib/hibernate/slf4j-log4j12-1.5.8.jar,\
+ about.ini,\
+ about.mappings,\
+ about.properties,\
+ hibernate_icon.gif,\
+ plugin.properties,\
+ lib/hibernate/cglib-2.2.jar,\
+ lib/hibernate/commons-collections-3.1.jar,\
+ lib/hibernate/hibernate-jmx.jar
+jars.compile.order = org.hibernate.mediator.jar
+source.org.hibernate.mediator.jar = src/
+output.org.hibernate.mediator.jar = bin/
+src.includes = src/,\
+ about.html
+bin.excludes = lib/.cvsignore
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/hibernate_icon.gif
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/hibernate_icon.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/annotations/ejb3-persistence.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/annotations/ejb3-persistence.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/annotations/hibernate-annotations.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/annotations/hibernate-annotations.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/annotations/hibernate-commons-annotations.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/annotations/hibernate-commons-annotations.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/annotations/hibernate-entitymanager.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/annotations/hibernate-entitymanager.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/annotations/hibernate-validator.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/annotations/hibernate-validator.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/bsh-core-2.0b4.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/bsh-core-2.0b4.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/antlr-2.7.6.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/antlr-2.7.6.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/asm-attrs.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/asm-attrs.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/asm.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/asm.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/c3p0-0.9.1.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/c3p0-0.9.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/cglib-2.2.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/cglib-2.2.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/commons-collections-3.1.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/commons-collections-3.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/commons-logging-1.0.4.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/commons-logging-1.0.4.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/concurrent-1.3.2.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/concurrent-1.3.2.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/connector.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/connector.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/dom4j-1.6.1.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/dom4j-1.6.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/ehcache-1.2.3.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/ehcache-1.2.3.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/hibernate-jmx.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/hibernate-jmx.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/hibernate3.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/hibernate3.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jaas.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jaas.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/javassist.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/javassist.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jboss-cache.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jboss-cache.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jboss-common.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jboss-common.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jboss-jmx.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jboss-jmx.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jboss-system.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jboss-system.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jdbc2_0-stdext.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jdbc2_0-stdext.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jgroups-2.2.8.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jgroups-2.2.8.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jta.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/jta.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/log4j-1.2.15.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/log4j-1.2.15.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/oscache-2.1.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/oscache-2.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/proxool-0.8.3.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/proxool-0.8.3.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/slf4j-api-1.5.8.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/slf4j-api-1.5.8.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/slf4j-log4j12-1.5.8.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/slf4j-log4j12-1.5.8.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/swarmcache-1.0rc2.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/hibernate/swarmcache-1.0rc2.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/tools/freemarker.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/tools/freemarker.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/tools/hibernate-tools.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/tools/hibernate-tools.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/tools/jtidy-r8-20060801.jar
===================================================================
(Binary files differ)
Property changes on:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/lib/tools/jtidy-r8-20060801.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/plugin.properties
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/plugin.properties
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/plugin.properties 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,3 @@
+#Properties file for org.hibernate.mediator
+Bundle-Vendor.0 = JBoss by Red Hat
+Bundle-Name.0 = Hibernate Tools
\ No newline at end of file
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/ConsoleConfigClassLoader.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/ConsoleConfigClassLoader.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/ConsoleConfigClassLoader.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,286 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.hibernate.mediator;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Vector;
+import java.util.jar.JarFile;
+
+import org.hibernate.mediator.stubs.util.ReflectHelper;
+
+/**
+ * Workaround for jdk disgrace with open jar files & native libs,
+ * which is a reason of locked, "undelete" files.
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class ConsoleConfigClassLoader extends URLClassLoader {
+
+ protected HashSet<String> setJarFileNames2Close = new HashSet<String>();
+
+ public ConsoleConfigClassLoader(URL[] urls, ClassLoader parent) {
+ super(urls, parent);
+ }
+
+ public void close() {
+ setJarFileNames2Close.clear();
+ closeClassLoader(this);
+ finalizeNativeLibs(this);
+ cleanupJarFileFactory();
+ }
+
+ /**
+ * cleanup jar file factory cache
+ */
+ @SuppressWarnings({ "nls", "unchecked" })
+ public boolean cleanupJarFileFactory()
+ {
+ boolean res = false;
+ Class classJarURLConnection = null;
+ try {
+ classJarURLConnection =
ReflectHelper.classForName("sun.net.www.protocol.jar.JarURLConnection");
+ } catch (ClassNotFoundException e) {
+ //ignore
+ }
+ if (classJarURLConnection == null) {
+ return res;
+ }
+ Field f = null;
+ try {
+ f = classJarURLConnection.getDeclaredField("factory");
+ } catch (NoSuchFieldException e) {
+ //ignore
+ }
+ if (f == null) {
+ return res;
+ }
+ f.setAccessible(true);
+ Object obj = null;
+ try {
+ obj = f.get(null);
+ } catch (IllegalAccessException e) {
+ //ignore
+ }
+ if (obj == null) {
+ return res;
+ }
+ Class classJarFileFactory = obj.getClass();
+ //
+ HashMap fileCache = null;
+ try {
+ f = classJarFileFactory.getDeclaredField("fileCache");
+ f.setAccessible(true);
+ obj = f.get(null);
+ if (obj instanceof HashMap) {
+ fileCache = (HashMap)obj;
+ }
+ } catch (NoSuchFieldException e) {
+ } catch (IllegalAccessException e) {
+ //ignore
+ }
+ HashMap urlCache = null;
+ try {
+ f = classJarFileFactory.getDeclaredField("urlCache");
+ f.setAccessible(true);
+ obj = f.get(null);
+ if (obj instanceof HashMap) {
+ urlCache = (HashMap)obj;
+ }
+ } catch (NoSuchFieldException e) {
+ } catch (IllegalAccessException e) {
+ //ignore
+ }
+ if (urlCache != null) {
+ HashMap urlCacheTmp = (HashMap)urlCache.clone();
+ Iterator it = urlCacheTmp.keySet().iterator();
+ while (it.hasNext()) {
+ obj = it.next();
+ if (!(obj instanceof JarFile)) {
+ continue;
+ }
+ JarFile jarFile = (JarFile)obj;
+ if (setJarFileNames2Close.contains(jarFile.getName())) {
+ try {
+ jarFile.close();
+ } catch (IOException e) {
+ //ignore
+ }
+ if (fileCache != null) {
+ fileCache.remove(urlCache.get(jarFile));
+ }
+ urlCache.remove(jarFile);
+ }
+ }
+ res = true;
+ } else if (fileCache != null) {
+ // urlCache := null
+ HashMap fileCacheTmp = (HashMap)fileCache.clone();
+ Iterator it = fileCacheTmp.keySet().iterator();
+ while (it.hasNext()) {
+ Object key = it.next();
+ obj = fileCache.get(key);
+ if (!(obj instanceof JarFile)) {
+ continue;
+ }
+ JarFile jarFile = (JarFile)obj;
+ if (setJarFileNames2Close.contains(jarFile.getName())) {
+ try {
+ jarFile.close();
+ } catch (IOException e) {
+ //ignore
+ }
+ fileCache.remove(key);
+ }
+ }
+ res = true;
+ }
+ setJarFileNames2Close.clear();
+ return res;
+ }
+
+ /**
+ * close jar files of cl
+ * @param cl
+ * @return
+ */
+ @SuppressWarnings( { "nls", "unchecked" })
+ public boolean closeClassLoader(ClassLoader cl) {
+ boolean res = false;
+ if (cl == null) {
+ return res;
+ }
+ Class classURLClassLoader = URLClassLoader.class;
+ Field f = null;
+ try {
+ f = classURLClassLoader.getDeclaredField("ucp");
+ } catch (NoSuchFieldException e1) {
+ //ignore
+ }
+ if (f != null) {
+ f.setAccessible(true);
+ Object obj = null;
+ try {
+ obj = f.get(cl);
+ } catch (IllegalAccessException e1) {
+ //ignore
+ }
+ if (obj != null) {
+ final Object ucp = obj;
+ f = null;
+ try {
+ f = ucp.getClass().getDeclaredField("loaders");
+ } catch (NoSuchFieldException e1) {
+ //ignore
+ }
+ if (f != null) {
+ f.setAccessible(true);
+ ArrayList loaders = null;
+ try {
+ loaders = (ArrayList) f.get(ucp);
+ res = true;
+ } catch (IllegalAccessException e1) {
+ //ignore
+ }
+ for (int i = 0; loaders != null && i < loaders.size(); i++) {
+ obj = loaders.get(i);
+ f = null;
+ try {
+ f = obj.getClass().getDeclaredField("jar");
+ } catch (NoSuchFieldException e) {
+ //ignore
+ }
+ if (f != null) {
+ f.setAccessible(true);
+ try {
+ obj = f.get(obj);
+ } catch (IllegalAccessException e1) {
+ // ignore
+ }
+ if (obj instanceof JarFile) {
+ final JarFile jarFile = (JarFile)obj;
+ setJarFileNames2Close.add(jarFile.getName());
+ //try {
+ // jarFile.getManifest().clear();
+ //} catch (IOException e) {
+ // // ignore
+ //}
+ try {
+ jarFile.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return res;
+ }
+
+ /**
+ * finalize native libraries
+ * @param cl
+ * @return
+ */
+ @SuppressWarnings({ "nls", "unchecked" })
+ public boolean finalizeNativeLibs(ClassLoader cl) {
+ boolean res = false;
+ Class classClassLoader = ClassLoader.class;
+ java.lang.reflect.Field nativeLibraries = null;
+ try {
+ nativeLibraries = classClassLoader.getDeclaredField("nativeLibraries");
+ } catch (NoSuchFieldException e1) {
+ //ignore
+ }
+ if (nativeLibraries == null) {
+ return res;
+ }
+ nativeLibraries.setAccessible(true);
+ Object obj = null;
+ try {
+ obj = nativeLibraries.get(cl);
+ } catch (IllegalAccessException e1) {
+ //ignore
+ }
+ if (!(obj instanceof Vector)) {
+ return res;
+ }
+ res = true;
+ Vector java_lang_ClassLoader_NativeLibrary = (Vector)obj;
+ for (Object lib : java_lang_ClassLoader_NativeLibrary) {
+ java.lang.reflect.Method finalize = null;
+ try {
+ finalize = lib.getClass().getDeclaredMethod("finalize", new Class[0]);
+ } catch (NoSuchMethodException e) {
+ //ignore
+ }
+ if (finalize != null) {
+ finalize.setAccessible(true);
+ try {
+ finalize.invoke(lib, new Object[0]);
+ } catch (IllegalAccessException e) {
+ } catch (InvocationTargetException e) {
+ //ignore
+ }
+ }
+ }
+ return res;
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/ConsoleQueryParameter.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/ConsoleQueryParameter.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/ConsoleQueryParameter.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,166 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.hibernate.mediator;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Currency;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.TimeZone;
+
+import org.hibernate.mediator.stubs.HibernateStub;
+import org.hibernate.mediator.stubs.NullableTypeStub;
+import org.hibernate.mediator.stubs.TableStub;
+import org.hibernate.mediator.stubs.TypeStub;
+
+
+public class ConsoleQueryParameter {
+
+ static private final Object NULL_MARKER = null; //new Object() { public String
toString() { return "[null]"; } };
+
+ static final Map<TypeStub, String> typeFormats = new HashMap<TypeStub,
String>();
+ static {
+ addTypeFormat(HibernateStub.BOOLEAN, Boolean.TRUE );
+ addTypeFormat(HibernateStub.BYTE, Byte.valueOf((byte) 42));
+ addTypeFormat(HibernateStub.BIG_INTEGER, BigInteger.valueOf(42));
+ addTypeFormat(HibernateStub.SHORT, Short.valueOf((short) 42));
+ addTypeFormat(HibernateStub.CALENDAR, new GregorianCalendar());
+ addTypeFormat(HibernateStub.CALENDAR_DATE, new GregorianCalendar());
+ addTypeFormat(HibernateStub.INTEGER, Integer.valueOf(42));
+ addTypeFormat(HibernateStub.INTEGER, Integer.valueOf(42));
+ addTypeFormat(HibernateStub.BIG_DECIMAL, new BigDecimal(42.0));
+ addTypeFormat(HibernateStub.CHARACTER, Character.valueOf('h'));
+ addTypeFormat(HibernateStub.CLASS, TableStub.class);
+ addTypeFormat(HibernateStub.CURRENCY, Currency.getInstance(Locale.getDefault()));
+ addTypeFormat(HibernateStub.DATE, new Date());
+ addTypeFormat(HibernateStub.DOUBLE, Double.valueOf(42.42));
+ addTypeFormat(HibernateStub.FLOAT, Float.valueOf((float)42.42));
+ addTypeFormat(HibernateStub.LOCALE, Locale.getDefault());
+ addTypeFormat(HibernateStub.LONG, Long.valueOf(42));
+ addTypeFormat(HibernateStub.STRING, "a string"); //$NON-NLS-1$
+ addTypeFormat(HibernateStub.TEXT, "a text"); //$NON-NLS-1$
+ addTypeFormat(HibernateStub.TIME, new Date());
+ addTypeFormat(HibernateStub.TIMESTAMP, new Date());
+ addTypeFormat(HibernateStub.TIMEZONE, TimeZone.getDefault());
+ addTypeFormat(HibernateStub.TRUE_FALSE, Boolean.TRUE);
+ addTypeFormat(HibernateStub.YES_NO, Boolean.TRUE);
+ }
+
+
+ private static void addTypeFormat(NullableTypeStub nullableType, Object value) {
+ typeFormats.put(nullableType, nullableType.toString(value));
+ }
+ String name;
+ NullableTypeStub type;
+ Object value;
+
+ public ConsoleQueryParameter(ConsoleQueryParameter cqp) {
+ name = cqp.name;
+ type = cqp.type;
+ value = cqp.value;
+ }
+
+ public ConsoleQueryParameter() {
+
+ }
+
+ public ConsoleQueryParameter(String name, NullableTypeStub type, Object value) {
+ this.name = name;
+ this.type = type;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public NullableTypeStub getType() {
+ return type;
+ }
+
+ public void setType(NullableTypeStub type) {
+ this.type = type;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public void setValue(Object value) {
+ //if(value == null) { throw new IllegalArgumentException("Value must not be set to
null"); }
+ this.value = value;
+ }
+
+ public String getValueAsString() {
+ if(isNull()) return ""; //$NON-NLS-1$
+ return type.toString(getValue());
+ }
+
+ public void setValueFromString(String value) {
+ try {
+ Object object = type.fromStringValue(value);
+ setValue(object);
+ } catch(Exception he) {
+ setNull();
+ }
+ }
+
+
+ public String getDefaultFormat() {
+ if(type!=null) {
+ Object object = typeFormats.get(type);
+ if(object!=null) {
+ return object.toString();
+ }
+ }
+ return "<unknown>"; //$NON-NLS-1$
+ }
+
+ public static Set<TypeStub> getPossibleTypes() {
+ return typeFormats.keySet();
+ }
+
+ public void setNull() {
+ setValue( NULL_MARKER );
+ }
+
+ public boolean isNull() {
+ return getValue()==NULL_MARKER;
+ }
+
+ public Object getValueForQuery() {
+ if(isNull()) {
+ return null;
+ } else {
+ return getValue();
+ }
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/FakeDelegatingDriver.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/FakeDelegatingDriver.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/FakeDelegatingDriver.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.hibernate.mediator;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.util.Properties;
+
+public class FakeDelegatingDriver implements Driver {
+ private Driver driver;
+
+ public FakeDelegatingDriver(Driver d) {
+ this.driver = d;
+ }
+ public boolean acceptsURL(String u) throws SQLException {
+ return this.driver.acceptsURL(u);
+ }
+ public Connection connect(String u, Properties p) throws SQLException {
+ return this.driver.connect(u, p);
+ }
+ public int getMajorVersion() {
+ return this.driver.getMajorVersion();
+ }
+ public int getMinorVersion() {
+ return this.driver.getMinorVersion();
+ }
+ public DriverPropertyInfo[] getPropertyInfo(String u, Properties p)
+ throws SQLException {
+ return this.driver.getPropertyInfo(u, p);
+ }
+ public boolean jdbcCompliant() {
+ return this.driver.jdbcCompliant();
+ }
+}
\ No newline at end of file
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/FakeTransactionManagerLookup.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/FakeTransactionManagerLookup.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/FakeTransactionManagerLookup.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,238 @@
+package org.hibernate.mediator;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAResource;
+
+// TODO: replace these imports
+import org.hibernate.HibernateException;
+import org.hibernate.connection.ConnectionProvider;
+import org.hibernate.connection.ConnectionProviderFactory;
+import org.hibernate.transaction.TransactionManagerLookup;
+
+// TODO: ConfigurationStubFactory use this class via string name
+public class FakeTransactionManagerLookup implements TransactionManagerLookup {
+
+ public TransactionManager getTransactionManager(Properties props)
+ throws HibernateException {
+ if ( FakeTransactionManager.INSTANCE == null ) {
+ FakeTransactionManager.INSTANCE = new FakeTransactionManager(props);
+ }
+ return FakeTransactionManager.INSTANCE;
+ }
+
+ public String getUserTransactionName() {
+ return null; //throw new UnsupportedOperationException();
+ }
+
+ public Object getTransactionIdentifier(Transaction transaction) {
+ return transaction;
+ }
+
+}
+
+class FakeTransactionManager implements TransactionManager {
+
+ public static FakeTransactionManager INSTANCE;
+
+ private FakeTransaction current;
+ ConnectionProvider connections;
+
+ public FakeTransactionManager(Properties props) {
+ connections = ConnectionProviderFactory.newConnectionProvider();
+ }
+
+ public void begin() throws NotSupportedException, SystemException {
+ current = new FakeTransaction(this);
+ current.begin();
+ }
+
+ public void commit() throws RollbackException, HeuristicMixedException,
+ HeuristicRollbackException, SecurityException,
+ IllegalStateException, SystemException {
+ if(current!=null) current.commit();
+ }
+
+
+ public int getStatus() throws SystemException {
+ if(current!=null) {
+ return current.getStatus();
+ } else {
+ return Status.STATUS_NO_TRANSACTION;
+ }
+ }
+
+ public Transaction getTransaction() throws SystemException {
+ return current;
+ }
+
+ public void resume(Transaction tx) throws InvalidTransactionException,
+ IllegalStateException, SystemException {
+ current = (FakeTransaction) tx;
+ }
+
+ public void rollback() throws IllegalStateException, SecurityException,
+ SystemException {
+ if(current!=null) current.rollback();
+ }
+
+ public void setRollbackOnly() throws IllegalStateException, SystemException {
+ if(current!=null) current.setRollbackOnly();
+ }
+
+ public void setTransactionTimeout(int t) throws SystemException {
+ }
+
+ public Transaction suspend() throws SystemException {
+ Transaction result = current;
+ current = null;
+ return result;
+ }
+
+ public FakeTransaction getCurrent() {
+ return current;
+ }
+
+ void endCurrent(FakeTransaction tx) {
+ if (current==tx) current=null;
+ }
+
+}
+
+class FakeTransaction implements Transaction {
+
+ int status;
+ private Connection connection;
+ List<Synchronization> synchronizations = new ArrayList<Synchronization>();
+ private FakeTransactionManager transactionManager;
+
+ FakeTransaction(FakeTransactionManager transactionManager) {
+ status = Status.STATUS_NO_TRANSACTION;
+ this.transactionManager = transactionManager;
+ }
+
+ public void begin() throws SystemException {
+ try {
+ connection = transactionManager.connections.getConnection();
+ }
+ catch (SQLException sqle) {
+
+ sqle.printStackTrace();
+ throw new SystemException(sqle.toString());
+ }
+ status = Status.STATUS_ACTIVE;
+ }
+
+ public void commit() throws RollbackException, HeuristicMixedException,
+ HeuristicRollbackException, SecurityException,
+ IllegalStateException, SystemException {
+
+ if (status == Status.STATUS_MARKED_ROLLBACK) {
+ rollback();
+ }
+ else {
+ status = Status.STATUS_PREPARING;
+
+ for (Synchronization s : synchronizations) {
+ s.beforeCompletion();
+ }
+
+ status = Status.STATUS_COMMITTING;
+
+ try {
+ connection.commit();
+ connection.close();
+ }
+ catch (SQLException sqle) {
+ status = Status.STATUS_UNKNOWN;
+ throw new SystemException();
+ }
+
+ status = Status.STATUS_COMMITTED;
+
+ for (Synchronization s : synchronizations) {
+ s.afterCompletion(status);
+ }
+
+ //status = Status.STATUS_NO_TRANSACTION;
+ transactionManager.endCurrent(this);
+ }
+
+ }
+
+ public boolean delistResource(XAResource arg0, int arg1)
+ throws IllegalStateException, SystemException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean enlistResource(XAResource arg0) throws RollbackException,
+ IllegalStateException, SystemException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public int getStatus() throws SystemException {
+ return status;
+ }
+
+ public void registerSynchronization(Synchronization sync)
+ throws RollbackException, IllegalStateException, SystemException {
+ synchronizations.add(sync);
+ }
+
+ public void rollback() throws IllegalStateException, SystemException {
+
+ status = Status.STATUS_ROLLING_BACK;
+
+// Synch.beforeCompletion() should *not* be called for rollbacks
+// for ( int i=0; i<synchronizations.size(); i++ ) {
+// Synchronization s = (Synchronization) synchronizations.get(i);
+// s.beforeCompletion();
+// }
+
+ status = Status.STATUS_ROLLEDBACK;
+
+ try {
+ connection.rollback();
+ connection.close();
+ }
+ catch (SQLException sqle) {
+ status = Status.STATUS_UNKNOWN;
+ throw new SystemException();
+ }
+
+ for (Synchronization s : synchronizations) {
+ s.afterCompletion(status);
+ }
+
+ //status = Status.STATUS_NO_TRANSACTION;
+ transactionManager.endCurrent(this);
+ }
+
+ public void setRollbackOnly() throws IllegalStateException, SystemException {
+ status = Status.STATUS_MARKED_ROLLBACK;
+ }
+
+ void setConnection(Connection connection) {
+ this.connection = connection;
+ }
+
+ public Connection getConnection() {
+ return connection;
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/MediatorPlugin.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/MediatorPlugin.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/MediatorPlugin.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.hibernate.mediator;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class MediatorPlugin extends Plugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.hibernate.mediator";
//$NON-NLS-1$
+
+ // The shared instance
+ private static MediatorPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public MediatorPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ setPlugin(this);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ setPlugin(null);
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static MediatorPlugin getDefault() {
+ return plugin;
+ }
+
+ private static void setPlugin(MediatorPlugin plugin) {
+ MediatorPlugin.plugin = plugin;
+ }
+
+ /**
+ * Log message
+ *
+ */
+ private static void log(int severity, String message, Throwable e) {
+ getDefault().getLog().log(new Status(severity, PLUGIN_ID, message, e));
+ }
+
+ /**
+ * Short exception log
+ *
+ */
+ public static void logException(Throwable e) {
+ log(IStatus.ERROR, e.getMessage(), e);
+ }
+
+ /**
+ * Short error log call
+ *
+ */
+ public static void logError(String message) {
+ log(IStatus.ERROR, message, null);
+ }
+
+ /**
+ * Short warning log call
+ *
+ */
+ public static void logWarning(String message) {
+ log(IStatus.WARNING, message, null);
+ }
+
+ /**
+ * Short information log call
+ *
+ */
+ public static void logInfo(String message) {
+ log(IStatus.INFO, message, null);
+ }
+
+
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/Messages.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/Messages.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/Messages.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,47 @@
+package org.hibernate.mediator;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.hibernate.mediator.Messages";
//$NON-NLS-1$
+ public static String ConsoleConfiguration_connection_profile_not_found;
+ public static String ConsoleConfiguration_could_not_access;
+ public static String ConsoleConfiguration_could_not_configure_entity_resolver;
+ public static String ConsoleConfiguration_could_not_configure_naming_strategy;
+ public static String ConsoleConfiguration_could_not_create_jpa_based_configuration;
+ public static String ConsoleConfiguration_could_not_load_annotationconfiguration;
+ public static String ConsoleConfiguration_could_not_load_jpa_configuration;
+ public static String ConsoleConfiguration_could_not_parse_configuration;
+ //public static String
ConsoleConfiguration_factory_not_closed_before_build_new_factory;
+ public static String ConsoleConfiguration_invalid_configuration;
+ public static String ConsoleConfiguration_persistence_unit_not_found;
+ public static String ConsoleConfiguration_problems_while_loading_database_driverclass;
+ //public static String JavaPage_no_info;
+ public static String JavaPage_not_allowed;
+ //public static String KnownConfigurations_could_not_write_state;
+ //public static String KnownConfigurations_hibernate_log;
+ //public static String KnownConfigurations_unknown;
+ public static String DefaultExecutionContext_existing_classloader;
+ //public static String ClassNode_uninitialized_proxy;
+ //public static String ConfigurationNode_mapped_entities;
+ //public static String NodeFactory_unknown;
+ //public static String PersistentCollectionNode_could_not_access_property_value;
+ //public static String
AbstractConsoleConfigurationPreferences_could_not_load_prop_file;
+ //public static String AbstractConsoleConfigurationPreferences_name_not_null_or_empty;
+ //public static String AbstractConsoleConfigurationPreferences_unknown;
+ //public static String
StandAloneConsoleConfigurationPreferences_could_not_resolve_classpaths;
+ //public static String StandAloneConsoleConfigurationPreferences_errors_while_parsing;
+ public static String PluginFileAppender_missing_plugin_state_location;
+ //public static String PluginLogAppender_missing_layout_for_appender;
+ public static String EntityPropertySource_identifier;
+ public static String EntityPropertySource_properties;
+ public static String DynamicSQLPreviewView_caused_by;
+ public static String DynamicSQLPreviewView_manipulation_of;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/Messages.properties
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/Messages.properties
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/Messages.properties 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,33 @@
+ConsoleConfiguration_could_not_access=Could not access
+ConsoleConfiguration_could_not_configure_entity_resolver=Could not configure entity
resolver
+ConsoleConfiguration_could_not_configure_naming_strategy=Could not configure naming
strategy
+ConsoleConfiguration_could_not_create_jpa_based_configuration=Could not create JPA based
Configuration
+ConsoleConfiguration_could_not_load_annotationconfiguration=Could not load
AnnotationConfiguration
+ConsoleConfiguration_could_not_load_jpa_configuration=Could not load JPA Configuration
+ConsoleConfiguration_could_not_parse_configuration=Could not parse configuration:
+ConsoleConfiguration_factory_not_closed_before_build_new_factory=Factory were not closed
before attempting to built a new factory.
+ConsoleConfiguration_invalid_configuration=invalid configuration
+ConsoleConfiguration_persistence_unit_not_found=Persistence unit not found:
''{0}''.
+ConsoleConfiguration_problems_while_loading_database_driverclass=Problems while loading
database driverclass ({0})
+JavaPage_no_info=<no info>
+JavaPage_not_allowed=System.exit not allowed\!
+KnownConfigurations_could_not_write_state=Could not write state
+KnownConfigurations_hibernate_log=Hibernate Log -
+KnownConfigurations_unknown=<unknown>
+DefaultExecutionContext_existing_classloader=Existing classloader is not equal to the
previously installed classloader\! Existing={0} Previous={1}
+ClassNode_uninitialized_proxy=(uninitialized proxy)
+ConfigurationNode_mapped_entities=Mapped entities
+NodeFactory_unknown=Unknown ->
+PersistentCollectionNode_could_not_access_property_value=Could not access property value
+AbstractConsoleConfigurationPreferences_could_not_load_prop_file=Could not load property
file
+AbstractConsoleConfigurationPreferences_name_not_null_or_empty=Name cannot be null or
empty
+AbstractConsoleConfigurationPreferences_unknown=<unknown>
+StandAloneConsoleConfigurationPreferences_could_not_resolve_classpaths=Could not resolve
classpaths
+StandAloneConsoleConfigurationPreferences_errors_while_parsing=Errors while parsing
+PluginFileAppender_missing_plugin_state_location=Missing Plugin State Location.
+PluginLogAppender_missing_layout_for_appender=Missing layout for appender
+ConsoleConfiguration_connection_profile_not_found=Connection profile not found:
''{0}''.
+EntityPropertySource_identifier=Identifier
+EntityPropertySource_properties=Properties
+DynamicSQLPreviewView_caused_by=\nCaused by:\n
+DynamicSQLPreviewView_manipulation_of=Manipulation of
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/QueryInputModel.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/QueryInputModel.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/QueryInputModel.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,167 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.hibernate.mediator;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Observable;
+import java.util.Set;
+
+import org.hibernate.mediator.stubs.HibernateStub;
+
+/**
+ * Class for managing misc parameters and other inputs to a Query, Criteria etc.
+ *
+ * Currently only holds parameters.
+ *
+ * @author Max Rydahl Andersen
+ *
+ */
+public class QueryInputModel extends Observable {
+
+ List<ConsoleQueryParameter> parameters;
+ boolean ignoreParameters = false;
+
+ private Integer maxResults;
+
+ public QueryInputModel() {
+ parameters = new ArrayList<ConsoleQueryParameter>();
+ }
+
+ public int getParameterCount() {
+ return parameters.size();
+ }
+
+ public ConsoleQueryParameter[] getQueryParameters() {
+ return parameters.toArray(new ConsoleQueryParameter[parameters.size()]);
+ }
+
+ /** return a copy of the parameters currently in this model */
+ public ConsoleQueryParameter[] getQueryParametersForQuery() {
+ //pass 0-size array to guarantee Collection.toArray(T[]) will return new Array
instance
+ return ignoreParameters ? new ConsoleQueryParameter[0]
+ : parameters.toArray(new ConsoleQueryParameter[0]);
+ }
+
+ public QueryInputModel getCopyForQuery() {
+ QueryInputModel result = new QueryInputModel();
+
+ ConsoleQueryParameter[] queryParametersForQuery = getQueryParametersForQuery();
+ result.parameters = Arrays.asList( queryParametersForQuery );
+
+ result.maxResults = getMaxResults();
+ result.ignoreParameters = ignoreParameters;
+
+ return result;
+ }
+
+ public void addParameter(ConsoleQueryParameter cqp) {
+ parameters.add(cqp);
+ setChanged();
+ notifyObservers("addParameter"); //$NON-NLS-1$
+ }
+
+ public void removeParameter(ConsoleQueryParameter cqp) {
+ parameters.remove(cqp);
+ setChanged();
+ notifyObservers("removeParameter"); //$NON-NLS-1$
+ }
+
+ public void moveUp(ConsoleQueryParameter cqp) {
+ move(cqp, 1, parameters);
+ }
+
+ public void moveDown(ConsoleQueryParameter cqp) {
+ move(cqp, 1, parameters);
+ }
+
+ protected <T> void move(T tf, int shift, List<T> list) {
+ int i = list.indexOf(tf);
+
+ if(i>=0) {
+ if(i+shift<list.size() && i+shift>=0) {
+ list.remove(i);
+ list.add(i+shift, tf);
+ }
+ }
+ setChanged();
+ notifyObservers("move"); //$NON-NLS-1$
+ }
+
+ /** create a parameter which does not collide with any other parameter */
+ public ConsoleQueryParameter createUniqueParameter(String paramName) {
+ if(parameters.isEmpty()) {
+ return new ConsoleQueryParameter(paramName, HibernateStub.STRING, "");
//$NON-NLS-1$
+ } else {
+ ConsoleQueryParameter cqp = parameters.get(parameters.size()-1);
+ ConsoleQueryParameter c = new ConsoleQueryParameter(cqp);
+ c.setName(makeUnique(parameters.iterator(), paramName));
+ return c;
+ }
+ }
+
+ private static String makeUnique(Iterator<ConsoleQueryParameter> items, String
originalPropertyName) {
+ int cnt = 0;
+ String propertyName = originalPropertyName;
+ Set<String> uniqueNames = new HashSet<String>();
+
+ while ( items.hasNext() ) {
+ ConsoleQueryParameter element = items.next();
+ uniqueNames.add( element.getName() );
+ }
+
+ while( uniqueNames.contains(propertyName) ) {
+ cnt++;
+ propertyName = originalPropertyName + "-" + cnt; //$NON-NLS-1$
+ }
+
+ return propertyName;
+ }
+
+
+ public void setIgnoreParameters(boolean ignoreParameters) {
+ this.ignoreParameters = ignoreParameters;
+ setChanged();
+ notifyObservers();
+ }
+
+ public boolean ignoreParameters() {
+ return ignoreParameters;
+ }
+
+ public void clear() {
+ parameters.clear();
+ setChanged();
+ notifyObservers("clear"); //$NON-NLS-1$
+ }
+
+ public void setMaxResults(Integer maxResults) {
+ this.maxResults = maxResults;
+ }
+
+ public Integer getMaxResults() {
+ return maxResults;
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/execution/DefaultExecutionContext.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/execution/DefaultExecutionContext.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/execution/DefaultExecutionContext.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.hibernate.mediator.execution;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.eclipse.osgi.util.NLS;
+import org.hibernate.mediator.Messages;
+import org.hibernate.mediator.logging.CurrentContext;
+
+public class DefaultExecutionContext implements ExecutionContext {
+
+ final private ClassLoader configurationClassLoader;
+ private volatile int installs;
+ private Map<Thread, ClassLoader> previousLoaders = new WeakHashMap<Thread,
ClassLoader>();
+
+ final String key;
+
+ public DefaultExecutionContext(String key, ClassLoader loader) {
+ configurationClassLoader = loader;
+ this.key = key;
+ }
+
+ /* (non-Javadoc)
+ * @see org.hibernate.mediator.ExecutionContext#installLoader()
+ */
+ public synchronized void installLoader() {
+ installs++;
+ if(configurationClassLoader!=null &&
Thread.currentThread().getContextClassLoader() != configurationClassLoader) {
+ previousLoaders.put(Thread.currentThread(),
Thread.currentThread().getContextClassLoader() );
+ Thread.currentThread().setContextClassLoader(configurationClassLoader);
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see
org.hibernate.mediator.ExecutionContext#execute(org.hibernate.mediator.ExecutionContext.Command)
+ */
+ public synchronized Object execute(Command c) {
+ try {
+ CurrentContext.push( key );
+ installLoader();
+ return c.execute();
+ }
+ finally {
+ uninstallLoader();
+ CurrentContext.pop();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.hibernate.console.IExecutionContext#uninstallLoader()
+ */
+ public synchronized void uninstallLoader() {
+ installs--; // TODO: make more safe (synchronized) bookkeeping of the classloader
installation.
+
+ if(installs==0) {
+ ClassLoader cl = previousLoaders.get(Thread.currentThread() );
+ if(configurationClassLoader!=null &&
Thread.currentThread().getContextClassLoader() != configurationClassLoader) {
+ String out = NLS.bind(Messages.DefaultExecutionContext_existing_classloader,
Thread.currentThread().getContextClassLoader(), configurationClassLoader);
+ throw new IllegalStateException(out);
+ }
+
+ if(cl!=null) {
+ previousLoaders.remove(Thread.currentThread() );
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ }
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/execution/ExecutionContext.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/execution/ExecutionContext.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/execution/ExecutionContext.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.hibernate.mediator.execution;
+
+public interface ExecutionContext {
+
+ public interface Command {
+ public Object execute();
+ }
+
+ public abstract void installLoader();
+
+ public abstract Object execute(Command c);
+
+ public abstract void uninstallLoader();
+
+}
\ No newline at end of file
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/execution/ExecutionContextHolder.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/execution/ExecutionContextHolder.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/execution/ExecutionContextHolder.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.hibernate.mediator.execution;
+
+public interface ExecutionContextHolder {
+ public ExecutionContext getExecutionContext();
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/logging/CurrentContext.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/logging/CurrentContext.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/logging/CurrentContext.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,62 @@
+package org.hibernate.mediator.logging;
+
+import java.util.Hashtable;
+import java.util.Stack;
+
+/**
+ * CurrentContext is here to have one place where we can keep track on the
+ * "current" console configuration to allow logging to be seperated per
config.
+ *
+ */
+
+public class CurrentContext {
+
+ static Hashtable<Thread, Stack<Object>> map = new Hashtable<Thread,
Stack<Object>>();
+
+ private CurrentContext() {
+ }
+
+ public static int getDepth() {
+ Stack<Object> stack = map.get( Thread.currentThread() );
+ if ( stack == null )
+ return 0;
+ else
+ return stack.size();
+ }
+
+ public static Object pop() {
+ Thread key = Thread.currentThread();
+ Stack<Object> stack = map.get( key );
+ if ( stack != null && !stack.isEmpty() )
+ return (stack.pop() );
+ else
+ return null;
+ }
+
+ public static Object peek() {
+ Thread key = Thread.currentThread();
+ Stack<Object> stack = map.get( key );
+ if ( stack != null && !stack.isEmpty() )
+ return stack.peek();
+ else
+ return null;
+ }
+
+ public static void push(Object message) {
+ Thread key = Thread.currentThread();
+ Stack<Object> stack = map.get( key );
+
+ if ( stack == null ) {
+ stack = new Stack<Object>();
+ map.put( key, stack );
+ stack.push( message );
+ }
+ else {
+ stack.push( message );
+ }
+ }
+
+ static public void remove() {
+ map.remove( Thread.currentThread() );
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/preferences/ConsoleConfigurationPreferences.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/preferences/ConsoleConfigurationPreferences.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/preferences/ConsoleConfigurationPreferences.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.hibernate.mediator.preferences;
+
+import java.io.File;
+import java.io.Serializable;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.w3c.dom.Element;
+
+/**
+ * @author max
+ *
+ */
+public interface ConsoleConfigurationPreferences {
+
+ static final String PATH_TAG = "path"; //$NON-NLS-1$
+ static final String CLASSPATH_TAG = "classpath"; //$NON-NLS-1$
+ static final String MAPPING_TAG = "mapping"; //$NON-NLS-1$
+ static final String MAPPINGS_TAG = "mappings"; //$NON-NLS-1$
+ static final String HIBERNATE_PROPERTIES_TAG = "hibernate-properties";
//$NON-NLS-1$
+ static final String LOCATION_ATTRIB = "location"; //$NON-NLS-1$
+ static final String HIBERNATE_CONFIG_XML_TAG = "hibernate-config-xml";
//$NON-NLS-1$
+ static final String NAME_ATTRIB = "name"; //$NON-NLS-1$
+ static final String CONFIGURATION_TAG = "configuration"; //$NON-NLS-1$
+ static final String ANNOTATIONS_ATTRIB = "annotations"; //$NON-NLS-1$
+ static final String ENTITYRESOLVER_ATTRIB = "entityresolver"; //$NON-NLS-1$
+ static final String CONFIGURATION_MODE_ATTRIB = "configuration-factory";
//$NON-NLS-1$
+
+ // TODO: we should move this to some classhandler
+ static public class ConfigurationMode implements Serializable {
+
+ private static final long serialVersionUID = 1734677008665190162L;
+
+ private static final Map<String, ConfigurationMode> INSTANCES = new
HashMap<String, ConfigurationMode>();
+
+ public static final ConfigurationMode CORE = new ConfigurationMode( "CORE" );
//$NON-NLS-1$
+ public static final ConfigurationMode ANNOTATIONS = new ConfigurationMode(
"ANNOTATIONS" ); //$NON-NLS-1$
+ public static final ConfigurationMode JPA = new ConfigurationMode( "JPA" );
//$NON-NLS-1$
+
+ static {
+ INSTANCES.put( CORE.name, CORE );
+ INSTANCES.put( ANNOTATIONS.name, ANNOTATIONS );
+ INSTANCES.put( JPA.name, JPA );
+ }
+
+ private final String name;
+
+ public ConfigurationMode(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return name;
+ }
+
+ private Object readResolve() {
+ return INSTANCES.get( name );
+ }
+
+ public static ConfigurationMode parse(String name) {
+ ConfigurationMode rtn = INSTANCES.get( name );
+ if ( rtn == null ) {
+ // default is POJO
+ rtn = CORE;
+ }
+ return rtn;
+ }
+
+ public static String[] values(){
+ return INSTANCES.keySet().toArray(new String[INSTANCES.size()]);
+ }
+ }
+
+
+ public abstract ConfigurationMode getConfigurationMode();
+
+ public abstract String getName();
+
+ /**
+ * @return return non-null array of URLs for a customclasspath
+ */
+ public abstract URL[] getCustomClassPathURLS();
+
+ /**
+ * @return return non-null array of URLs for mapping files
+ */
+ public abstract File[] getMappingFiles();
+
+ public abstract Properties getProperties();
+
+ public abstract File getConfigXMLFile();
+
+ public abstract File getPropertyFile();
+
+ public abstract void writeStateTo(Element node);
+
+ public abstract void readStateFrom(Element element);
+
+ public abstract void setName(String name);
+
+ public abstract String getEntityResolverName();
+
+ public abstract String getPersistenceUnitName();
+
+ public abstract String getNamingStrategy();
+
+ /**
+ *
+ * @return null if ConnectionProfile was not specified
+ */
+ public abstract String getConnectionProfileName();
+
+ public abstract String getDialectName();
+}
\ No newline at end of file
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/AbstractTypeStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/AbstractTypeStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/AbstractTypeStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,12 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.type.AbstractType;
+
+public class AbstractTypeStub extends TypeStub {
+ protected AbstractType abstractType;
+
+ protected AbstractTypeStub(Object abstractType) {
+ super(abstractType);
+ this.abstractType = (AbstractType)abstractType;
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/AnyStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/AnyStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/AnyStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,13 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.Any;
+
+public class AnyStub extends SimpleValueStub {
+ protected Any any;
+
+ protected AnyStub(Object any) {
+ super(any);
+ this.any = (Any)any;
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ArrayStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ArrayStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ArrayStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,36 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.Array;
+
+public class ArrayStub extends ListStub {
+ protected Array array;
+
+ protected ArrayStub(Object array) {
+ super(array);
+ this.array = (Array)array;
+ }
+
+ public static ArrayStub newInstance(PersistentClassStub owner) {
+ return new ArrayStub(new Array(owner.persistentClass));
+ }
+
+ public void setElement(ValueStub element) {
+ array.setElement(element.value);
+ }
+
+ public void setCollectionTable(TableStub table) {
+ array.setCollectionTable(table.table);
+ }
+
+ public void setElementClassName(String elementClassName) {
+ array.setElementClassName(elementClassName);
+ }
+
+ public void setIndex(ValueStub index) {
+ array.setIndex(index.value);
+ }
+
+ public String getElementClassName() {
+ return array.getElementClassName();
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ArtifactCollectorStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ArtifactCollectorStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ArtifactCollectorStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,28 @@
+package org.hibernate.mediator.stubs;
+
+import java.io.File;
+
+import org.hibernate.tool.hbm2x.ArtifactCollector;
+
+public class ArtifactCollectorStub {
+
+ protected ArtifactCollector artifactCollector;
+
+ protected ArtifactCollectorStub(Object artifactCollector) {
+ this.artifactCollector = (ArtifactCollector)artifactCollector;
+ }
+
+ public static ArtifactCollectorStub newInstance() {
+ return new ArtifactCollectorStub(new ArtifactCollector());
+ }
+
+ public File[] getFiles(String string) {
+ return null;
+ }
+
+ public void formatFiles() {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/BagStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/BagStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/BagStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,21 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.Bag;
+
+public class BagStub extends CollectionStub {
+ protected Bag bag;
+
+ protected BagStub(Object bag) {
+ super(bag);
+ this.bag = (Bag)bag;
+ }
+
+ public static BagStub newInstance(PersistentClassStub owner) {
+ return new BagStub(new Bag(owner.persistentClass));
+ }
+
+ @Override
+ public Object accept(ValueVisitorStub visitor) {
+ return visitor.accept(this);
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/Cfg2HbmToolStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/Cfg2HbmToolStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/Cfg2HbmToolStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,23 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.tool.hbm2x.Cfg2HbmTool;
+
+public class Cfg2HbmToolStub {
+ protected Cfg2HbmTool cfg2HbmTool;
+
+ protected Cfg2HbmToolStub(Object cfg2HbmTool) {
+ this.cfg2HbmTool = (Cfg2HbmTool)cfg2HbmTool;
+ }
+
+ public static Cfg2HbmToolStub newInstance() {
+ return new Cfg2HbmToolStub(new Cfg2HbmTool());
+ }
+
+ public String getTag(PersistentClassStub persistentClass) {
+ return cfg2HbmTool.getTag(persistentClass.persistentClass);
+ }
+
+ public String getTag(PropertyStub property) {
+ return cfg2HbmTool.getTag(property.property);
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ClassMetadataStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ClassMetadataStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ClassMetadataStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,46 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.metadata.ClassMetadata;
+import org.hibernate.type.Type;
+
+public class ClassMetadataStub {
+ protected ClassMetadata classMetadata;
+
+ protected ClassMetadataStub(Object classMetadata) {
+ this.classMetadata = (ClassMetadata)classMetadata;
+ }
+
+ public String[] getPropertyNames() {
+ return classMetadata.getPropertyNames();
+ }
+
+ public TypeStub[] getPropertyTypes() {
+ Type[] types = classMetadata.getPropertyTypes();
+ TypeStub[] res = new TypeStub[types.length];
+ for (int i = 0; i < types.length; i++) {
+ res[i] = TypeStubFactory.createTypeStub(types[i]);
+ }
+ return res;
+ }
+
+ public String getIdentifierPropertyName() {
+ return classMetadata.getIdentifierPropertyName();
+ }
+
+ public Object getPropertyValue(Object baseObject, String name, EntityModeStub pojo) {
+ return classMetadata.getPropertyValue(baseObject, name, pojo.entityMode);
+ }
+
+ public String getEntityName() {
+ return classMetadata.getEntityName();
+ }
+
+ public TypeStub getIdentifierType() {
+ return TypeStubFactory.createTypeStub(classMetadata.getIdentifierType());
+ }
+
+ public Class<?> getMappedClass(EntityModeStub pojo) {
+ return classMetadata.getMappedClass(pojo.entityMode);
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/CollectionMetadataStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/CollectionMetadataStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/CollectionMetadataStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,15 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.metadata.CollectionMetadata;
+
+public class CollectionMetadataStub {
+ protected CollectionMetadata collectionMetadata;
+
+ protected CollectionMetadataStub(Object collectionMetadata) {
+ this.collectionMetadata = (CollectionMetadata)collectionMetadata;
+ }
+
+ public TypeStub getElementType() {
+ return TypeStubFactory.createTypeStub(collectionMetadata.getElementType());
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/CollectionStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/CollectionStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/CollectionStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,65 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.FetchMode;
+import org.hibernate.mapping.Collection;
+
+public abstract class CollectionStub extends ValueStub {
+
+ protected Collection collection;
+
+ protected CollectionStub(Object collection) {
+ super(collection);
+ this.collection = (Collection)collection;
+ }
+
+ public void setCollectionTable(TableStub table) {
+ collection.setCollectionTable(table.table);
+ }
+
+ public void setKey(KeyValueStub key) {
+ collection.setKey(key.keyValue);
+ }
+
+ public void setLazy(boolean lazy) {
+ collection.setLazy(lazy);
+ }
+
+ public void setRole(String role) {
+ collection.setRole(role);
+ }
+
+ public void setElement(ValueStub element) {
+ collection.setElement(element.value);
+ }
+
+ public void setFetchMode(FetchModeStub fetchMode) {
+ if (FetchModeStub.DEFAULT.equals(fetchMode)) {
+ collection.setFetchMode(FetchMode.DEFAULT);
+ } else if (FetchModeStub.SELECT.equals(fetchMode)) {
+ collection.setFetchMode(FetchMode.SELECT);
+ } else if (FetchModeStub.JOIN.equals(fetchMode)) {
+ collection.setFetchMode(FetchMode.JOIN);
+ } else if (FetchModeStub.SUBSELECT.equals(fetchMode)) {
+ }
+ }
+
+ public ValueStub getElement() {
+ return ValueStubFactory.createValueStub(collection.getElement());
+ }
+
+ public TableStub getCollectionTable() {
+ return new TableStub(collection.getCollectionTable());
+ }
+
+ public KeyValueStub getKey() {
+ return (KeyValueStub)ValueStubFactory.createValueStub(collection.getKey());
+ }
+
+ public boolean isOneToMany() {
+ return collection.isOneToMany();
+ }
+
+ public boolean isInverse() {
+ return collection.isInverse();
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/CollectionTypeStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/CollectionTypeStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/CollectionTypeStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,22 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.type.CollectionType;
+
+public class CollectionTypeStub extends AbstractTypeStub {
+
+ protected CollectionType collectionType;
+
+ protected CollectionTypeStub(Object collectionType) {
+ super(collectionType);
+ this.collectionType = (CollectionType)collectionType;
+ }
+
+ public String getRole() {
+ return collectionType.getRole();
+ }
+
+ public boolean isArrayType() {
+ return collectionType.isArrayType();
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ColumnStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ColumnStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ColumnStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,68 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.Column;
+
+public class ColumnStub {
+ public static final int DEFAULT_LENGTH = 255;
+ public static final int DEFAULT_PRECISION = 19;
+ public static final int DEFAULT_SCALE = 2;
+
+ protected Column column;
+
+ protected ColumnStub(Object column) {
+ this.column = (Column)column;
+ }
+
+ public static ColumnStub newInstance() {
+ return new ColumnStub(new Column());
+ }
+
+ public static ColumnStub newInstance(String columnName) {
+ return new ColumnStub(new Column(columnName));
+ }
+
+ public String getSqlType() {
+ return column.getSqlType();
+ }
+
+ public void setSqlType(String sqlType) {
+ column.setSqlType(sqlType);
+ }
+
+ public String getSqlType(DialectStub dialect, MappingStub mapping) {
+ return column.getSqlType(dialect.dialect, mapping.mapping);
+ }
+
+ public ValueStub getValue() {
+ return ValueStubFactory.createValueStub(column.getValue());
+ }
+
+ public String getName() {
+ return column.getName();
+ }
+
+ public boolean isNullable() {
+ return column.isNullable();
+ }
+
+ public boolean isUnique() {
+ return column.isUnique();
+ }
+
+ public Integer getSqlTypeCode() {
+ return column.getSqlTypeCode();
+ }
+
+ public int getLength() {
+ return column.getLength();
+ }
+
+ public int getPrecision() {
+ return column.getPrecision();
+ }
+
+ public int getScale() {
+ return column.getScale();
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ComponentStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ComponentStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ComponentStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,42 @@
+package org.hibernate.mediator.stubs;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.hibernate.mapping.Component;
+import org.hibernate.mapping.Property;
+
+public class ComponentStub extends SimpleValueStub {
+ protected Component component;
+
+ protected ComponentStub(Object component) {
+ super(component);
+ this.component = (Component)component;
+ }
+
+ public String getComponentClassName() {
+ return component.getComponentClassName();
+ }
+
+ public PersistentClassStub getOwner() {
+ return PersistentClassStubFactory.createPersistentClassStub(component.getOwner());
+ }
+
+ public String getParentProperty() {
+ return component.getParentProperty();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Iterator<PropertyStub> getPropertyIterator() {
+ Iterator<Property> it =
(Iterator<Property>)component.getPropertyIterator();
+ ArrayList<PropertyStub> al = new ArrayList<PropertyStub>();
+ while (it.hasNext()) {
+ al.add(new PropertyStub(it.next()));
+ }
+ return al.iterator();
+ }
+
+ public boolean isEmbedded() {
+ return component.isEmbedded();
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ConfigurationStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ConfigurationStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ConfigurationStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,196 @@
+package org.hibernate.mediator.stubs;
+
+import java.io.File;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import org.eclipse.osgi.util.NLS;
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mediator.Messages;
+import org.hibernate.mediator.FakeDelegatingDriver;
+import org.hibernate.mediator.stubs.util.ReflectHelper;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
+import org.hibernate.tool.ide.completion.HQLCodeAssist;
+import org.xml.sax.EntityResolver;
+
+public class ConfigurationStub {
+
+ private Map<String, FakeDelegatingDriver> fakeDrivers = new HashMap<String,
FakeDelegatingDriver>();
+
+ // configuration != null - by default
+ protected Configuration configuration;
+
+ protected ConfigurationStub(Configuration configuration) {
+ //Class.forName(className)
+ //Method ReflectionUtils.findPublicMethod(Class declaringClass, "isOpen",
+ // new Class[]());
+ this.configuration = configuration;
+ }
+
+ protected Configuration getConfiguration() {
+ return configuration;
+ }
+
+ public void cleanUp() {
+ Iterator<FakeDelegatingDriver> it = fakeDrivers.values().iterator();
+ while (it.hasNext()) {
+ try {
+ DriverManager.deregisterDriver(it.next());
+ } catch (SQLException e) {
+ // ignore
+ }
+ }
+ fakeDrivers.clear();
+ }
+
+ public void buildMappings() {
+ configuration.buildMappings();
+ }
+
+ // TODO: temporary should be protected and/or SettingsStub?
+ public SettingsStub buildSettings() {
+ return new SettingsStub(configuration.buildSettings());
+ }
+
+ protected SessionFactory buildSessionFactory() {
+ return configuration.buildSessionFactory();
+ }
+
+ public EntityResolver getEntityResolver() {
+ return configuration.getEntityResolver();
+ }
+
+ public IHQLCodeAssistStub getHQLCodeAssist() {
+ return new IHQLCodeAssistStub(new HQLCodeAssist(configuration));
+ }
+
+ // TODO: temporary should be protected and/or NamingStrategyStub?
+ public NamingStrategyStub getNamingStrategy() {
+ return new NamingStrategyStub(configuration.getNamingStrategy());
+ }
+
+ public boolean hasNamingStrategy() {
+ return (configuration.getNamingStrategy() != null);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Iterator<PersistentClassStub> getClassMappings() {
+ Iterator<PersistentClass> it =
(Iterator<PersistentClass>)configuration.getClassMappings();
+ ArrayList<PersistentClassStub> arr = new ArrayList<PersistentClassStub>();
+ while (it.hasNext()) {
+ arr.add(PersistentClassStubFactory.createPersistentClassStub(it.next()));
+ }
+ return arr.iterator();
+ }
+
+ // TODO: temporary should be protected and/or PersistentClassStub?
+ public PersistentClassStub getClassMapping(String entityName) {
+ return
PersistentClassStubFactory.createPersistentClassStub(configuration.getClassMapping(entityName));
+ }
+
+ // TODO: temporary should be protected and/or MappingsStub?
+ public MappingsStub createMappings() {
+ return new MappingsStub(configuration.createMappings());
+ }
+
+ // TODO: temporary should be protected and/or MappingsStub?
+ public MappingStub buildMapping() {
+ return new MappingStub(configuration.buildMapping());
+ }
+
+ public static interface IExporterNewOutputDir {
+ File getNewOutputDir(POJOClassStub element, File outputdir4FileNew);
+ }
+
+ public HibernateMappingExporterStub createHibernateMappingExporter(File folder2Gen,
final IExporterNewOutputDir enod) {
+ return new HibernateMappingExporterStub(this, folder2Gen) {
+ @SuppressWarnings("unchecked")
+ protected void exportPOJO(Map additionalContext, POJOClassStub element) {
+ File outputdir4FileOld = getOutputDirectory();
+ File outputdir4FileNew = enod.getNewOutputDir(element, outputdir4FileOld);
+ if (!outputdir4FileNew.exists()) {
+ outputdir4FileNew.mkdirs();
+ }
+ setOutputDirectory(outputdir4FileNew);
+ super.exportPOJO(additionalContext, element);
+ setOutputDirectory(outputdir4FileOld);
+ }
+ };
+ }
+
+ @SuppressWarnings("unchecked")
+ public Iterator<Throwable> doSchemaExport() {
+ SchemaExport export = new SchemaExport(configuration);
+ export.create(false, true);
+ if (!export.getExceptions().isEmpty()) {
+ return (Iterator<Throwable>)export.getExceptions().iterator();
+ }
+ return null;
+ }
+
+ public void updateExporter(ExporterStub exporter) {
+ exporter.setConfiguration(configuration);
+ }
+
+ public Properties getProperties() {
+ return configuration.getProperties();
+ }
+
+ public String getProperty(String propertyName) {
+ return configuration.getProperty(propertyName);
+ }
+
+ /**
+ * DriverManager checks what classloader a class is loaded from thus we register a
FakeDriver
+ * that we know is loaded "properly" which delegates all it class to the real
driver. By doing
+ * so we can convince DriverManager that we can use any dynamically loaded driver.
+ *
+ * @param driverClassName
+ */
+ @SuppressWarnings("unchecked")
+ protected void registerFakeDriver(String driverClassName) {
+ if (driverClassName != null) {
+ try {
+ Class<Driver> driverClass = ReflectHelper.classForName(driverClassName);
+ if (!fakeDrivers.containsKey(driverClassName)) { // To avoid "double
registration"
+ FakeDelegatingDriver fakeDelegatingDriver = new FakeDelegatingDriver(
+ driverClass.newInstance());
+ DriverManager.registerDriver(fakeDelegatingDriver);
+ fakeDrivers.put(driverClassName, fakeDelegatingDriver);
+ }
+ } catch (ClassNotFoundException e) {
+ String out = NLS
+ .bind(
+ Messages.ConsoleConfiguration_problems_while_loading_database_driverclass,
+ driverClassName);
+ throw new HibernateConsoleRuntimeException(out, e);
+ } catch (InstantiationException e) {
+ String out = NLS
+ .bind(
+ Messages.ConsoleConfiguration_problems_while_loading_database_driverclass,
+ driverClassName);
+ throw new HibernateConsoleRuntimeException(out, e);
+ } catch (IllegalAccessException e) {
+ String out = NLS
+ .bind(
+ Messages.ConsoleConfiguration_problems_while_loading_database_driverclass,
+ driverClassName);
+ throw new HibernateConsoleRuntimeException(out, e);
+ } catch (SQLException e) {
+ String out = NLS
+ .bind(
+ Messages.ConsoleConfiguration_problems_while_loading_database_driverclass,
+ driverClassName);
+ throw new HibernateConsoleRuntimeException(out, e);
+ }
+ }
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ConfigurationStubFactory.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ConfigurationStubFactory.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ConfigurationStubFactory.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,412 @@
+package org.hibernate.mediator.stubs;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.dom4j.DocumentException;
+import org.dom4j.Node;
+import org.dom4j.io.DOMWriter;
+import org.eclipse.datatools.connectivity.IConnectionProfile;
+import org.eclipse.datatools.connectivity.ProfileManager;
+import org.eclipse.osgi.util.NLS;
+import org.hibernate.HibernateException;
+import org.hibernate.MappingException;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.cfg.JDBCMetaDataConfiguration;
+import org.hibernate.cfg.NamingStrategy;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.resolver.DialectFactory;
+import org.hibernate.mediator.Messages;
+import org.hibernate.mediator.preferences.ConsoleConfigurationPreferences;
+import
org.hibernate.mediator.preferences.ConsoleConfigurationPreferences.ConfigurationMode;
+import org.hibernate.mediator.stubs.util.ReflectHelper;
+import org.hibernate.mediator.stubs.util.StringHelper;
+import org.hibernate.util.ConfigHelper;
+import org.hibernate.util.XMLHelper;
+import org.w3c.dom.Document;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+
+public class ConfigurationStubFactory {
+
+ private ConsoleConfigurationPreferences prefs = null;
+
+ public ConfigurationStubFactory(ConsoleConfigurationPreferences prefs) {
+ this.prefs = prefs;
+ }
+
+ public ConfigurationStub createConfiguration() {
+ ConfigurationStub res = new ConfigurationStub(new Configuration());
+ return res;
+ }
+
+ public ConfigurationStubJDBCMetaData createConfigurationJDBCMetaData() {
+ ConfigurationStubJDBCMetaData res = new ConfigurationStubJDBCMetaData(new
JDBCMetaDataConfiguration());
+ return res;
+ }
+
+ public ConfigurationStub createConfiguration(ConfigurationStub cfg, boolean
includeMappings) {
+ Configuration localCfg = cfg == null ? null : cfg.getConfiguration();
+ Properties properties = prefs.getProperties();
+ if (properties != null) {
+ // to fix: JBIDE-5839 - setup this property: false is default value
+ // to make hibernate tools diff hibernate versions compatible
+ if (properties.getProperty("hibernate.search.autoregister_listeners") ==
null) { //$NON-NLS-1$
+ properties.setProperty("hibernate.search.autoregister_listeners",
"false"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ // in case the transaction manager is empty then we need to inject a faketm since
+ // hibernate will still try and instantiate it.
+ String str =
properties.getProperty("hibernate.transaction.manager_lookup_class");
//$NON-NLS-1$
+ if (str != null && StringHelper.isEmpty(str)) {
+ properties
+ .setProperty(
+ "hibernate.transaction.manager_lookup_class",
"org.hibernate.mediator.FakeTransactionManagerLookup"); //$NON-NLS-1$
//$NON-NLS-2$
+ // properties.setProperty( "hibernate.transaction.factory_class",
"");
+ }
+ }
+ if (localCfg == null) {
+ localCfg = buildConfiguration(properties, includeMappings);
+ } else {
+ // Properties origProperties = cfg.getProperties();
+ // origProperties.putAll(properties);
+ // cfg.setProperties(origProperties);
+ // TODO: this is actually only for jdbc reveng...
+ // localCfg = configureStandardConfiguration( includeMappings, localCfg, properties
);
+ }
+ // non-running databases + i havent been needed until now...
+ // TODO: jpa configuration ?
+ if (includeMappings) {
+ File[] mappingFiles = prefs.getMappingFiles();
+ for (int i = 0; i < mappingFiles.length; i++) {
+ File hbm = mappingFiles[i];
+ localCfg = localCfg.addFile(hbm);
+ }
+ }
+ // TODO: HBX-
+ localCfg.setProperty("hibernate.temp.use_jdbc_metadata_defaults",
"false"); //$NON-NLS-1$//$NON-NLS-2$
+ localCfg.setProperty(Environment.HBM2DDL_AUTO, "false"); //$NON-NLS-1$
+ ConfigurationStub res = new ConfigurationStub(localCfg);
+ // here both setProperties and configxml have had their chance to tell which
databasedriver
+ // is needed.
+ res.registerFakeDriver(localCfg.getProperty(Environment.DRIVER));
+ // autoConfigureDialect(localCfg); Disabled for now since it causes very looong
timeouts for
+ return res;
+ }
+
+ private Configuration buildAnnotationConfiguration() throws ClassNotFoundException,
+ InstantiationException, IllegalAccessException {
+ Class<?> clazz = ReflectHelper
+ .classForName("org.hibernate.cfg.AnnotationConfiguration",
ConfigurationStubFactory.class); //$NON-NLS-1$
+ Configuration annotationConfig = (Configuration)clazz.newInstance();
+ return annotationConfig;
+ }
+
+ private Configuration buildJPAConfiguration(String persistenceUnit, Properties
properties,
+ String entityResolver, boolean includeMappings) {
+ if (StringHelper.isEmpty(persistenceUnit)) {
+ persistenceUnit = null;
+ }
+ try {
+ Map<Object, Object> overrides = new HashMap<Object, Object>();
+ if (properties != null) {
+ overrides.putAll(properties);
+ }
+ if (StringHelper.isNotEmpty(prefs.getNamingStrategy())) {
+ overrides.put("hibernate.ejb.naming_strategy", prefs.getNamingStrategy());
//$NON-NLS-1$
+ }
+ if (StringHelper.isNotEmpty(prefs.getDialectName())) {
+ overrides.put("hibernate.dialect", prefs.getDialectName()); //$NON-NLS-1$
+ }
+ if (!includeMappings) {
+ overrides.put("hibernate.archive.autodetection", "none");
//$NON-NLS-1$//$NON-NLS-2$
+ }
+ Class<?> clazz = ReflectHelper.classForName(
+ "org.hibernate.ejb.Ejb3Configuration", ConfigurationStubFactory.class);
//$NON-NLS-1$
+ Object ejb3cfg = clazz.newInstance();
+
+ if (StringHelper.isNotEmpty(entityResolver)) {
+ Class<?> resolver = ReflectHelper.classForName(entityResolver,
this.getClass());
+ Object object = resolver.newInstance();
+ Method method = clazz.getMethod(
+ "setEntityResolver", new Class[] { EntityResolver.class });//$NON-NLS-1$
+ method.invoke(ejb3cfg, new Object[] { object });
+ }
+
+ Method method = clazz.getMethod("configure", new Class[] { String.class,
Map.class }); //$NON-NLS-1$
+ if (method.invoke(ejb3cfg, new Object[] { persistenceUnit, overrides }) == null) {
+ String out = NLS.bind(
+ Messages.ConsoleConfiguration_persistence_unit_not_found,
+ persistenceUnit);
+ throw new HibernateConsoleRuntimeException(out, null);
+ }
+
+ method = clazz.getMethod("getHibernateConfiguration", new
Class[0]);//$NON-NLS-1$
+ Object obj = method.invoke(ejb3cfg, (Object[]) null);
+ Configuration invoke = (Configuration)obj;
+ invoke = configureConnectionProfile(invoke);
+
+ return invoke;
+ } catch (HibernateConsoleRuntimeException he) {
+ throw he;
+ } catch (Exception e) {
+ throw new HibernateConsoleRuntimeException(
+ Messages.ConsoleConfiguration_could_not_create_jpa_based_configuration,
+ e);
+ }
+ }
+
+ private Configuration buildConfiguration(Properties properties, boolean includeMappings)
{
+ Configuration localCfg = null;
+ if (prefs.getConfigurationMode().equals(ConfigurationMode.ANNOTATIONS)) {
+ try {
+ localCfg = buildAnnotationConfiguration();
+ localCfg = configureStandardConfiguration(includeMappings, localCfg, properties);
+ } catch (HibernateConsoleRuntimeException he) {
+ throw he;
+ } catch (Exception e) {
+ throw new HibernateConsoleRuntimeException(
+ Messages.ConsoleConfiguration_could_not_load_annotationconfiguration,
+ e);
+ }
+ } else if (prefs.getConfigurationMode().equals(ConfigurationMode.JPA)) {
+ try {
+ localCfg = buildJPAConfiguration(prefs.getPersistenceUnitName(), properties, prefs
+ .getEntityResolverName(), includeMappings);
+ } catch (HibernateConsoleRuntimeException he) {
+ throw he;
+ } catch (Exception e) {
+ throw new HibernateConsoleRuntimeException(
+ Messages.ConsoleConfiguration_could_not_load_jpa_configuration, e);
+ }
+ } else {
+ localCfg = new Configuration();
+ localCfg = configureStandardConfiguration(includeMappings, localCfg, properties);
+ }
+ return localCfg;
+ }
+
+ private Configuration configureStandardConfiguration(final boolean includeMappings,
+ Configuration localCfg, Properties properties) {
+ if (properties != null) {
+ localCfg = localCfg.setProperties(properties);
+ }
+ EntityResolver entityResolver = XMLHelper.DEFAULT_DTD_RESOLVER;
+ if (StringHelper.isNotEmpty(prefs.getEntityResolverName())) {
+ try {
+ entityResolver = (EntityResolver) ReflectHelper.classForName(
+ prefs.getEntityResolverName()).newInstance();
+ } catch (Exception c) {
+ throw new HibernateConsoleRuntimeException(
+ Messages.ConsoleConfiguration_could_not_configure_entity_resolver
+ + prefs.getEntityResolverName(), c);
+ }
+ }
+ localCfg.setEntityResolver(entityResolver);
+ if (StringHelper.isNotEmpty(prefs.getNamingStrategy())) {
+ try {
+ NamingStrategy ns = (NamingStrategy) ReflectHelper.classForName(
+ prefs.getNamingStrategy()).newInstance();
+ localCfg.setNamingStrategy(ns);
+ } catch (Exception c) {
+ throw new HibernateConsoleRuntimeException(
+ Messages.ConsoleConfiguration_could_not_configure_naming_strategy
+ + prefs.getNamingStrategy(), c);
+ }
+ }
+ localCfg = loadConfigurationXML(localCfg, includeMappings, entityResolver);
+ localCfg = configureConnectionProfile(localCfg);
+
+ // replace dialect if it is set in preferences
+ if (StringHelper.isNotEmpty(prefs.getDialectName())) {
+ localCfg.setProperty("hibernate.dialect", prefs.getDialectName());
//$NON-NLS-1$
+ }
+
+ return localCfg;
+ }
+
+ @SuppressWarnings("unchecked")
+ private Configuration loadConfigurationXML(Configuration localCfg, boolean
includeMappings,
+ EntityResolver entityResolver) {
+ File configXMLFile = prefs.getConfigXMLFile();
+ if (!includeMappings) {
+ org.dom4j.Document doc;
+ XMLHelper xmlHelper = new XMLHelper();
+ InputStream stream = null;
+ String resourceName = "<unknown>"; //$NON-NLS-1$
+ if (configXMLFile != null) {
+ resourceName = configXMLFile.toString();
+ try {
+ stream = new FileInputStream(configXMLFile);
+ } catch (FileNotFoundException e1) {
+ throw new HibernateConsoleRuntimeException(
+ Messages.ConsoleConfiguration_could_not_access + configXMLFile,
+ e1);
+ }
+ } else {
+ resourceName = "/hibernate.cfg.xml"; //$NON-NLS-1$
+ if (checkHibernateResoureExistence(resourceName)) {
+ stream = ConfigHelper.getResourceAsStream(resourceName); // simulate
hibernate's
+ // default look up
+ } else {
+ return localCfg;
+ }
+ }
+
+ try {
+ List<Throwable> errors = new ArrayList<Throwable>();
+
+ doc = xmlHelper.createSAXReader(resourceName, errors, entityResolver).read(
+ new InputSource(stream));
+ if (errors.size() != 0) {
+ throw new MappingException(
+ Messages.ConsoleConfiguration_invalid_configuration, errors
+ .get(0));
+ }
+
+ List<Node> list = doc.getRootElement()
+ .element("session-factory").elements("mapping"); //$NON-NLS-1$
//$NON-NLS-2$
+ for (Node element : list) {
+ element.getParent().remove(element);
+ }
+
+ DOMWriter dw = new DOMWriter();
+ Document document = dw.write(doc);
+ return localCfg.configure(document);
+
+ } catch (DocumentException e) {
+ throw new HibernateException(
+ Messages.ConsoleConfiguration_could_not_parse_configuration
+ + resourceName, e);
+ } finally {
+ try {
+ if (stream != null)
+ stream.close();
+ } catch (IOException ioe) {
+ // log.warn( "could not close input stream for: " + resourceName, ioe );
+ }
+ }
+ } else {
+ if (configXMLFile != null) {
+ return localCfg.configure(configXMLFile);
+ } else {
+ Configuration resultCfg = localCfg;
+ if (checkHibernateResoureExistence("/hibernate.cfg.xml")) { //$NON-NLS-1$
+ resultCfg = localCfg.configure();
+ }
+ return resultCfg;
+ }
+ }
+ }
+
+ private boolean checkHibernateResoureExistence(String resource) {
+ InputStream is = null;
+ try {
+ is = ConfigHelper.getResourceAsStream(resource);
+ } catch (HibernateException e) {
+ // just ignore
+ } finally {
+ try {
+ if (is != null)
+ is.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ return (is != null);
+ }
+
+ private Configuration configureConnectionProfile(Configuration localCfg) {
+ String connectionProfile = prefs.getConnectionProfileName();
+ if (connectionProfile == null) {
+ return localCfg;
+ }
+ IConnectionProfile profile = ProfileManager.getInstance().getProfileByName(
+ connectionProfile);
+ if (profile != null) {
+ refreshProfile(profile);
+ //
+ final Properties invokeProperties = localCfg.getProperties();
+ // set this property to null!
+ invokeProperties.remove(Environment.DATASOURCE);
+ localCfg.setProperties(invokeProperties);
+ Properties cpProperties = profile.getProperties(profile.getProviderId());
+ // seems we should not setup dialect here
+ // String dialect =
+ //
"org.hibernate.dialect.HSQLDialect";//cpProperties.getProperty("org.eclipse.datatools.connectivity.db.driverClass");
+ // invoke.setProperty(Environment.DIALECT, dialect);
+ String driver = cpProperties
+ .getProperty("org.eclipse.datatools.connectivity.db.driverClass");
//$NON-NLS-1$
+ localCfg.setProperty(Environment.DRIVER, driver);
+ // TODO:
+ @SuppressWarnings("unused")
+ String driverJarPath = cpProperties.getProperty("jarList"); //$NON-NLS-1$
+ String url =
cpProperties.getProperty("org.eclipse.datatools.connectivity.db.URL");
//$NON-NLS-1$
+ // url += "/";// +
+ //
cpProperties.getProperty("org.eclipse.datatools.connectivity.db.databaseName");
+ localCfg.setProperty(Environment.URL, url);
+ String user = cpProperties
+ .getProperty("org.eclipse.datatools.connectivity.db.username");
//$NON-NLS-1$
+ if (null != user && user.length() > 0) {
+ localCfg.setProperty(Environment.USER, user);
+ }
+ String pass = cpProperties
+ .getProperty("org.eclipse.datatools.connectivity.db.password");
//$NON-NLS-1$
+ if (null != pass && pass.length() > 0) {
+ localCfg.setProperty(Environment.PASS, pass);
+ }
+ } else {
+ String out = NLS.bind(
+ Messages.ConsoleConfiguration_connection_profile_not_found,
+ connectionProfile);
+ throw new HibernateConsoleRuntimeException(out, null);
+ }
+ return localCfg;
+ }
+
+ @SuppressWarnings("unused")
+ private void autoConfigureDialect(Configuration localCfg) {
+ if (localCfg.getProperty(Environment.DIALECT) == null) {
+ String url = localCfg.getProperty(Environment.URL);
+ String user = localCfg.getProperty(Environment.USER);
+ String pass = localCfg.getProperty(Environment.PASS);
+ Connection connection = null;
+ try {
+ connection = DriverManager.getConnection(url, user, pass);
+ // SQL Dialect:
+ Dialect dialect = DialectFactory.buildDialect(localCfg.getProperties(), connection);
+ localCfg.setProperty(Environment.DIALECT, dialect.toString());
+ } catch (SQLException e) {
+ // can't determine dialect
+ }
+ if (connection != null) {
+ try {
+ connection.close();
+ } catch (SQLException e) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ public static void refreshProfile(IConnectionProfile profile) {
+ // refresh profile (refresh jpa connection):
+ // get fresh information about current db structure and update error markers
+ if (profile.getConnectionState() == IConnectionProfile.CONNECTED_STATE) {
+ profile.disconnect(null);
+ }
+ profile.connect(null);
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ConfigurationStubJDBCMetaData.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ConfigurationStubJDBCMetaData.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ConfigurationStubJDBCMetaData.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,48 @@
+package org.hibernate.mediator.stubs;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.hibernate.cfg.JDBCMetaDataConfiguration;
+
+public class ConfigurationStubJDBCMetaData extends ConfigurationStub {
+
+ protected JDBCMetaDataConfiguration jdbcMetaDataConfiguration;
+
+ protected ConfigurationStubJDBCMetaData(JDBCMetaDataConfiguration configuration) {
+ super(configuration);
+ jdbcMetaDataConfiguration = configuration;
+ }
+
+ public void setProperties(Properties properties) {
+ jdbcMetaDataConfiguration.setProperties(properties);
+ }
+
+ public void setPreferBasicCompositeIds(boolean flag) {
+ jdbcMetaDataConfiguration.setPreferBasicCompositeIds(flag);
+ }
+
+ public void setReverseEngineeringStrategy(ReverseEngineeringStrategyStub
reverseEngineeringStrategy) {
+ jdbcMetaDataConfiguration.setReverseEngineeringStrategy(reverseEngineeringStrategy.reverseEngineeringStrategy);
+ }
+
+ public void readFromJDBC() {
+ jdbcMetaDataConfiguration.readFromJDBC();
+ }
+
+ public ArrayList<TableStub> getTableMappingsArr() {
+ ArrayList<TableStub> arr = new ArrayList<TableStub>();
+ Iterator<?> it = jdbcMetaDataConfiguration.getTableMappings();
+ while (it.hasNext() ) {
+ Object table = it.next();
+ arr.add(new TableStub(table));
+ }
+ return arr;
+ }
+
+ public Iterator<TableStub> getTableMappingsIt() {
+ return getTableMappingsArr().iterator();
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ConnectionProviderStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ConnectionProviderStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ConnectionProviderStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,15 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.connection.ConnectionProvider;
+
+public class ConnectionProviderStub {
+ protected ConnectionProvider connectionProvider;
+
+ protected ConnectionProviderStub(Object connectionProvider) {
+ this.connectionProvider = (ConnectionProvider)connectionProvider;
+ }
+
+ public void close() {
+ connectionProvider.close();
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/DefaultDatabaseCollectorStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/DefaultDatabaseCollectorStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/DefaultDatabaseCollectorStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,39 @@
+package org.hibernate.mediator.stubs;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.hibernate.cfg.reveng.DefaultDatabaseCollector;
+import org.hibernate.mapping.Table;
+
+public class DefaultDatabaseCollectorStub {
+ protected DefaultDatabaseCollector defaultDatabaseCollector;
+
+ protected DefaultDatabaseCollectorStub(Object defaultDatabaseCollector) {
+ this.defaultDatabaseCollector = (DefaultDatabaseCollector)defaultDatabaseCollector;
+ }
+
+ public static DefaultDatabaseCollectorStub newInstance() {
+ return new DefaultDatabaseCollectorStub(new DefaultDatabaseCollector());
+ }
+
+ @SuppressWarnings("unchecked")
+ public Iterator<Entry<String, List<TableStub>>> getQualifierEntries()
{
+ Iterator<Map.Entry<String, List<Table>>> it =
defaultDatabaseCollector.getQualifierEntries();
+ HashMap<String, List<TableStub>> map = new HashMap<String,
List<TableStub>>();
+ while (it.hasNext()) {
+ Map.Entry<String, List<Table>> entry = it.next();
+ ArrayList<TableStub> arr = new ArrayList<TableStub>();
+ Iterator<Table> itValue = (Iterator<Table>)entry.getValue().iterator();
+ while (itValue.hasNext()) {
+ arr.add(new TableStub(itValue.next()));
+ }
+ map.put(entry.getKey(), arr);
+ }
+ return map.entrySet().iterator();
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/DefaultReverseEngineeringStrategyStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/DefaultReverseEngineeringStrategyStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/DefaultReverseEngineeringStrategyStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,17 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategy;
+
+public class DefaultReverseEngineeringStrategyStub extends ReverseEngineeringStrategyStub
{
+
+ protected DefaultReverseEngineeringStrategy defaultReverseEngineeringStrategy;
+
+ protected DefaultReverseEngineeringStrategyStub(Object
defaultReverseEngineeringStrategy) {
+ super(defaultReverseEngineeringStrategy);
+ this.defaultReverseEngineeringStrategy =
(DefaultReverseEngineeringStrategy)defaultReverseEngineeringStrategy;
+ }
+
+ public static DefaultReverseEngineeringStrategyStub newInstance() {
+ return new DefaultReverseEngineeringStrategyStub(new
DefaultReverseEngineeringStrategy());
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/DependantValueStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/DependantValueStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/DependantValueStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,13 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.DependantValue;
+
+public class DependantValueStub extends SimpleValueStub {
+ protected DependantValue dependantValue;
+
+ protected DependantValueStub(Object dependantValue) {
+ super(dependantValue);
+ this.dependantValue = (DependantValue)dependantValue;
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/DialectStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/DialectStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/DialectStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,15 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.dialect.Dialect;
+
+public class DialectStub {
+ protected Dialect dialect;
+
+ protected DialectStub(Object dialect) {
+ this.dialect = (Dialect)dialect;
+ }
+
+ public static DialectStub newInstance(final String dialectName) throws
InstantiationException, IllegalAccessException, ClassNotFoundException {
+ return new DialectStub(Class.forName(dialectName).newInstance());
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/EntityModeStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/EntityModeStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/EntityModeStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,16 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.EntityMode;
+
+public class EntityModeStub {
+
+ public static final EntityModeStub POJO = new EntityModeStub(EntityMode.POJO);
+ public static final EntityModeStub DOM4J = new EntityModeStub(EntityMode.DOM4J);
+ public static final EntityModeStub MAP = new EntityModeStub(EntityMode.MAP);
+
+ protected EntityMode entityMode;
+
+ protected EntityModeStub(Object entityMode) {
+ this.entityMode = (EntityMode)entityMode;
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/EntityTypeStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/EntityTypeStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/EntityTypeStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,20 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.type.EntityType;
+
+public class EntityTypeStub extends AbstractTypeStub {
+ protected EntityType entityType;
+
+ protected EntityTypeStub(Object entityType) {
+ super(entityType);
+ this.entityType = (EntityType)entityType;
+ }
+
+ public String getAssociatedEntityName() {
+ return entityType.getAssociatedEntityName();
+ }
+
+ public boolean isOneToOne() {
+ return entityType.isOneToOne();
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/EnumTypeStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/EnumTypeStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/EnumTypeStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,19 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.type.EnumType;
+
+public class EnumTypeStub {
+
+ public static final String ENUM = EnumType.ENUM;
+ public static final String TYPE = EnumType.TYPE;
+
+ protected EnumType enumType;
+
+ protected EnumTypeStub(Object enumType) {
+ this.enumType = (EnumType)enumType;
+ }
+
+ public static String getClassName() {
+ return EnumType.class.getName();
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/EnvironmentStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/EnvironmentStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/EnvironmentStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,46 @@
+package org.hibernate.mediator.stubs;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.hibernate.cfg.Environment;
+
+public class EnvironmentStub {
+ public static final String DIALECT = Environment.DIALECT;
+ public static final String DEFAULT_CATALOG = Environment.DEFAULT_CATALOG;
+ public static final String DEFAULT_SCHEMA = Environment.DEFAULT_SCHEMA;
+ public static final String DRIVER = Environment.DRIVER;
+ public static final String PASS = Environment.PASS;
+ public static final String SESSION_FACTORY_NAME = Environment.SESSION_FACTORY_NAME;
+ public static final String URL = Environment.URL;
+ public static final String USER = Environment.USER;
+
+ @SuppressWarnings("unchecked")
+ public static String[] extractHibernateProperties() {
+ try {
+ // TODO: extract property names from the Environment class in the users hibernate
+ // configuration.
+ Class cl = Environment.class;
+ List<String> names = new ArrayList<String>();
+ Field[] fields = cl.getFields();
+ for (int i = 0; i < fields.length; i++) {
+ Field field = fields[i];
+ if (Modifier.isStatic(field.getModifiers()) &&
field.getType().equals(String.class)) {
+ String str = (String) field.get(cl);
+ if (str.startsWith("hibernate.")) { //$NON-NLS-1$
+ names.add(str);
+ }
+ }
+ }
+ String[] propertyNames = (String[]) names.toArray(new String[names.size()]);
+ Arrays.sort(propertyNames);
+ return propertyNames;
+ } catch (IllegalAccessException iae) {
+ // ignore
+ return new String[0];
+ }
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ExporterStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ExporterStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ExporterStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,47 @@
+package org.hibernate.mediator.stubs;
+
+import java.io.File;
+import java.util.Properties;
+
+import org.hibernate.cfg.Configuration;
+import org.hibernate.tool.hbm2x.Exporter;
+
+public class ExporterStub {
+
+ protected Exporter exporter;
+
+ protected ExporterStub(Object exporter) {
+ this.exporter = (Exporter)exporter;
+ }
+
+ public void start() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setConfiguration(Configuration configuration) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setProperties(Properties props) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setArtifactCollector(ArtifactCollectorStub collector) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setOutputDirectory(File file) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setTemplatePath(String[] array) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/FetchModeStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/FetchModeStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/FetchModeStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,8 @@
+package org.hibernate.mediator.stubs;
+
+public enum FetchModeStub {
+ DEFAULT,
+ SELECT,
+ JOIN,
+ SUBSELECT
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ForeignKeyStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ForeignKeyStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ForeignKeyStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,49 @@
+package org.hibernate.mediator.stubs;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.hibernate.mapping.Column;
+import org.hibernate.mapping.ForeignKey;
+
+public class ForeignKeyStub {
+ protected ForeignKey foreignKey;
+
+ protected ForeignKeyStub(Object foreignKey) {
+ this.foreignKey = (ForeignKey)foreignKey;
+ }
+
+ public boolean containsColumn(ColumnStub column) {
+ return foreignKey.containsColumn(column.column);
+ }
+
+ public TableStub getReferencedTable() {
+ return new TableStub(foreignKey.getReferencedTable());
+ }
+
+ @SuppressWarnings("unchecked")
+ public Iterator<ColumnStub> columnIterator() {
+ Iterator<Column> it = (Iterator<Column>)foreignKey.getColumnIterator();
+ ArrayList<ColumnStub> al = new ArrayList<ColumnStub>();
+ while (it.hasNext()) {
+ al.add(new ColumnStub(it.next()));
+ }
+ return al.iterator();
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<ColumnStub> getReferencedColumns() {
+ Iterator<Column> it = foreignKey.getReferencedColumns().iterator();
+ ArrayList<ColumnStub> al = new ArrayList<ColumnStub>();
+ while (it.hasNext()) {
+ al.add(new ColumnStub(it.next()));
+ }
+ return al;
+ }
+
+ public boolean isReferenceToPrimaryKey() {
+ return foreignKey.isReferenceToPrimaryKey();
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/GenericExporterStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/GenericExporterStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/GenericExporterStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,28 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.tool.hbm2x.GenericExporter;
+
+public class GenericExporterStub extends ExporterStub {
+ protected GenericExporter genericExporter;
+
+ protected GenericExporterStub(Object genericExporter) {
+ super(genericExporter);
+ this.genericExporter = (GenericExporter)genericExporter;
+ }
+
+ public void setFilePattern(String property) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setTemplateName(String property) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setForEach(String property) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HQLCompletionProposalStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HQLCompletionProposalStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HQLCompletionProposalStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,50 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.tool.ide.completion.HQLCompletionProposal;
+
+public class HQLCompletionProposalStub {
+
+ public static final int ENTITY_NAME = HQLCompletionProposal.ENTITY_NAME;
+ public static final int PROPERTY = HQLCompletionProposal.PROPERTY;
+ public static final int KEYWORD = HQLCompletionProposal.KEYWORD;
+ public static final int FUNCTION = HQLCompletionProposal.FUNCTION;
+ public static final int ALIAS_REF = HQLCompletionProposal.ALIAS_REF;
+
+ protected HQLCompletionProposal hqlCompletionProposal;
+
+ protected HQLCompletionProposalStub(Object hqlCompletionProposal) {
+ this.hqlCompletionProposal = (HQLCompletionProposal)hqlCompletionProposal;
+ }
+
+ public String getCompletion() {
+ return hqlCompletionProposal.getCompletion();
+ }
+
+ public int getReplaceStart() {
+ return hqlCompletionProposal.getReplaceStart();
+ }
+
+ public int getReplaceEnd() {
+ return hqlCompletionProposal.getReplaceEnd();
+ }
+
+ public int getCompletionKind() {
+ return hqlCompletionProposal.getCompletionKind();
+ }
+
+ public String getEntityName() {
+ return hqlCompletionProposal.getEntityName();
+ }
+
+ public String getSimpleName() {
+ return hqlCompletionProposal.getSimpleName();
+ }
+
+ public String getShortEntityName() {
+ return hqlCompletionProposal.getShortEntityName();
+ }
+
+ public PropertyStub getProperty() {
+ return new PropertyStub(hqlCompletionProposal.getProperty());
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateConfigurationExporterStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateConfigurationExporterStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateConfigurationExporterStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,29 @@
+package org.hibernate.mediator.stubs;
+
+import java.io.StringWriter;
+import java.util.Properties;
+
+import org.hibernate.tool.hbm2x.HibernateConfigurationExporter;
+
+public class HibernateConfigurationExporterStub extends ExporterStub {
+ protected HibernateConfigurationExporter hibernateConfigurationExporter;
+
+ protected HibernateConfigurationExporterStub(Object hibernateConfigurationExporter) {
+ super(hibernateConfigurationExporter);
+ this.hibernateConfigurationExporter =
(HibernateConfigurationExporter)hibernateConfigurationExporter;
+ }
+
+ public static HibernateConfigurationExporterStub newInstance() {
+ return new HibernateConfigurationExporterStub(new HibernateConfigurationExporter());
+ }
+
+ public void setCustomProperties(Properties props) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setOutput(StringWriter stringWriter) {
+ // TODO Auto-generated method stub
+
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateConsoleRuntimeException.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateConsoleRuntimeException.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateConsoleRuntimeException.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.hibernate.mediator.stubs;
+
+/**
+ * @author max
+ *
+ */
+public class HibernateConsoleRuntimeException extends RuntimeException {
+
+ private static final long serialVersionUID = -9056528343206573782L;
+
+ public HibernateConsoleRuntimeException(Throwable cause) {
+ super("HibernateConsoleRuntimeException", cause); //$NON-NLS-1$
+ }
+
+ public HibernateConsoleRuntimeException(String message) {
+ super(message);
+ }
+
+ public HibernateConsoleRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateMappingExporterStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateMappingExporterStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateMappingExporterStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,63 @@
+package org.hibernate.mediator.stubs;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.hibernate.tool.hbm2x.HibernateMappingExporter;
+
+public class HibernateMappingExporterStub {
+
+ protected HibernateMappingExporter hibernateMappingExporter;
+
+ protected HibernateMappingExporterStub(ConfigurationStub cfg, File outputdir) {
+ hibernateMappingExporter = new HibernateMappingExporter(cfg.configuration, outputdir);
+ }
+
+ public void setGlobalSettings(HibernateMappingGlobalSettingsStub hmgs) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void start() {
+ // TODO Auto-generated method stub
+
+ }
+
+ protected File getOutputDirectory() {
+ return hibernateMappingExporter.getOutputDirectory();
+ }
+
+ protected void setOutputDirectory(File outputdir) {
+ hibernateMappingExporter.setOutputDirectory(outputdir);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void exportPOJO(Map additionalContext, POJOClassStub element) {
+ // TODO: protected - call via reflection
+ Method m = null;
+ try {
+ m =
hibernateMappingExporter.getClass().getDeclaredMethod("exportPOJO");//$NON-NLS-1$
+ } catch (SecurityException e) {
+ //TODO:
+ } catch (NoSuchMethodException e) {
+ //TODO:
+ }
+ m.setAccessible(true);
+ try {
+ m.invoke(hibernateMappingExporter, additionalContext, element.pojoClass);
+ } catch (IllegalArgumentException e) {
+ //TODO:
+ } catch (IllegalAccessException e) {
+ //TODO:
+ } catch (InvocationTargetException e) {
+ //TODO:
+ }
+ }
+
+ public ArtifactCollectorStub getArtifactCollector() {
+ return new ArtifactCollectorStub(hibernateMappingExporter.getArtifactCollector());
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateMappingGlobalSettingsStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateMappingGlobalSettingsStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateMappingGlobalSettingsStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,21 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.tool.hbm2x.HibernateMappingGlobalSettings;
+
+public class HibernateMappingGlobalSettingsStub {
+
+ protected HibernateMappingGlobalSettings hibernateMappingGlobalSettings;
+
+ protected HibernateMappingGlobalSettingsStub(Object hibernateMappingGlobalSettings) {
+ this.hibernateMappingGlobalSettings =
(HibernateMappingGlobalSettings)hibernateMappingGlobalSettings;
+ }
+
+ public static HibernateMappingGlobalSettingsStub newInstance() {
+ return new HibernateMappingGlobalSettingsStub(new HibernateMappingGlobalSettings());
+ }
+
+ public void setDefaultAccess(String string) {
+ // TODO Auto-generated method stub
+
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,39 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.Hibernate;
+
+public class HibernateStub {
+ public static final NullableTypeStub BOOLEAN = new NullableTypeStub(Hibernate.BOOLEAN);
+ public static final NullableTypeStub BYTE = new NullableTypeStub(Hibernate.BYTE);
+ public static final NullableTypeStub BIG_INTEGER = new
NullableTypeStub(Hibernate.BIG_INTEGER);
+ public static final NullableTypeStub SHORT = new NullableTypeStub(Hibernate.SHORT);
+ public static final NullableTypeStub CALENDAR = new
NullableTypeStub(Hibernate.CALENDAR);
+ public static final NullableTypeStub CALENDAR_DATE = new
NullableTypeStub(Hibernate.CALENDAR_DATE);
+ public static final NullableTypeStub INTEGER = new NullableTypeStub(Hibernate.INTEGER);
+ public static final NullableTypeStub BIG_DECIMAL = new
NullableTypeStub(Hibernate.BIG_DECIMAL);
+ public static final NullableTypeStub CHARACTER = new
NullableTypeStub(Hibernate.CHARACTER);
+ public static final NullableTypeStub CLASS = new NullableTypeStub(Hibernate.CLASS);
+ public static final NullableTypeStub CURRENCY = new
NullableTypeStub(Hibernate.CURRENCY);
+ public static final NullableTypeStub DATE = new NullableTypeStub(Hibernate.DATE);
+ public static final NullableTypeStub DOUBLE = new NullableTypeStub(Hibernate.DOUBLE);
+ public static final NullableTypeStub FLOAT = new NullableTypeStub(Hibernate.FLOAT);
+ public static final NullableTypeStub LOCALE = new NullableTypeStub(Hibernate.LOCALE);
+ public static final NullableTypeStub LONG = new NullableTypeStub(Hibernate.LONG);
+ public static final NullableTypeStub STRING = new NullableTypeStub(Hibernate.STRING);
+ public static final NullableTypeStub TEXT = new NullableTypeStub(Hibernate.TEXT);
+ public static final NullableTypeStub TIME = new NullableTypeStub(Hibernate.TIME);
+ public static final NullableTypeStub TIMESTAMP = new
NullableTypeStub(Hibernate.TIMESTAMP);
+ public static final NullableTypeStub TIMEZONE = new
NullableTypeStub(Hibernate.TIMEZONE);
+ public static final NullableTypeStub TRUE_FALSE = new
NullableTypeStub(Hibernate.TRUE_FALSE);
+ public static final NullableTypeStub YES_NO = new NullableTypeStub(Hibernate.YES_NO);
+
+ protected Hibernate hibernate;
+
+ protected HibernateStub(Object hibernate) {
+ this.hibernate = (Hibernate)hibernate;
+ }
+
+ public static boolean isInitialized(Object proxy) {
+ return Hibernate.isInitialized(proxy);
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HqlSqlTokenTypesStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HqlSqlTokenTypesStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HqlSqlTokenTypesStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,7 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.hql.antlr.HqlSqlTokenTypes;
+
+public class HqlSqlTokenTypesStub {
+ public static final int IDENT = HqlSqlTokenTypes.IDENT;
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IHQLCodeAssistStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IHQLCodeAssistStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IHQLCodeAssistStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,19 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.tool.ide.completion.HQLCodeAssist;
+
+public class IHQLCodeAssistStub {
+ protected HQLCodeAssist hqlCodeAssist;
+
+ protected IHQLCodeAssistStub(Object hqlCodeAssist) {
+ this.hqlCodeAssist = (HQLCodeAssist)hqlCodeAssist;
+ }
+
+ public static IHQLCodeAssistStub createHQLCodeAssist() {
+ return new IHQLCodeAssistStub(new HQLCodeAssist(null));
+ }
+
+ public void codeComplete(String query, int position, IHQLCompletionRequestorStub
requestor) {
+ hqlCodeAssist.codeComplete(query, position, requestor.hqlCompletionRequestor);
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IHQLCompletionRequestorStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IHQLCompletionRequestorStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IHQLCompletionRequestorStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,26 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.tool.ide.completion.HQLCompletionProposal;
+import org.hibernate.tool.ide.completion.IHQLCompletionRequestor;
+
+public abstract class IHQLCompletionRequestorStub {
+
+ protected IHQLCompletionRequestor hqlCompletionRequestor;
+
+ protected IHQLCompletionRequestorStub() {
+ hqlCompletionRequestor = new IHQLCompletionRequestor() {
+
+ public boolean accept(HQLCompletionProposal proposal) {
+ return IHQLCompletionRequestorStub.this.accept(new
HQLCompletionProposalStub(proposal));
+ }
+
+ public void completionFailure(String errorMessage) {
+ IHQLCompletionRequestorStub.this.completionFailure(errorMessage);
+ }
+
+ };
+ }
+
+ public abstract boolean accept(HQLCompletionProposalStub proposal);
+ public abstract void completionFailure(String errorMessage);
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IdentifierBagStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IdentifierBagStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IdentifierBagStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,18 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.IdentifierBag;
+
+public class IdentifierBagStub extends IdentifierCollectionStub {
+ protected IdentifierBag identifierBag;
+
+ protected IdentifierBagStub(Object identifierBag) {
+ super(identifierBag);
+ this.identifierBag = (IdentifierBag)identifierBag;
+ }
+
+ @Override
+ public Object accept(ValueVisitorStub visitor) {
+ return visitor.accept(this);
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IdentifierCollectionStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IdentifierCollectionStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IdentifierCollectionStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,13 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.IdentifierCollection;
+
+public abstract class IdentifierCollectionStub extends CollectionStub {
+ protected IdentifierCollection identifierCollection;
+
+ protected IdentifierCollectionStub(Object identifierCollection) {
+ super(identifierCollection);
+ this.identifierCollection = (IdentifierCollection)identifierCollection;
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ImmutableTypeStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ImmutableTypeStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ImmutableTypeStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,13 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.type.ImmutableType;
+
+public class ImmutableTypeStub extends NullableTypeStub {
+
+ protected ImmutableType immutableType;
+
+ protected ImmutableTypeStub(Object immutableType) {
+ super(immutableType);
+ this.immutableType = (ImmutableType)immutableType;
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IndexedCollectionStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IndexedCollectionStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IndexedCollectionStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,18 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.IndexedCollection;
+
+public abstract class IndexedCollectionStub extends CollectionStub {
+
+ protected IndexedCollection indexedCollection;
+
+ protected IndexedCollectionStub(Object indexedCollection) {
+ super(indexedCollection);
+ this.indexedCollection = (IndexedCollection)indexedCollection;
+ }
+
+ public void setIndex(ValueStub index) {
+ indexedCollection.setIndex(index.value);
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IntegerTypeStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IntegerTypeStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/IntegerTypeStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,13 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.type.IntegerType;
+
+public class IntegerTypeStub extends PrimitiveTypeStub {
+
+ protected IntegerType integerType;
+
+ protected IntegerTypeStub(Object integerType) {
+ super(integerType);
+ this.integerType = (IntegerType)integerType;
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JDBCReaderStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JDBCReaderStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JDBCReaderStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,25 @@
+package org.hibernate.mediator.stubs;
+
+import java.util.List;
+import java.util.Properties;
+
+import org.hibernate.cfg.JDBCReaderFactory;
+import org.hibernate.cfg.reveng.JDBCReader;
+
+public class JDBCReaderStub {
+
+ protected JDBCReader jdbcReader;
+
+ protected JDBCReaderStub(Properties cfg, SettingsStub settings,
ReverseEngineeringStrategyStub revengStrategy) {
+ jdbcReader = JDBCReaderFactory.newJDBCReader(cfg, settings.settings,
revengStrategy.reverseEngineeringStrategy);
+ }
+
+ public static JDBCReaderStub newInstance(Properties cfg, SettingsStub settings,
ReverseEngineeringStrategyStub revengStrategy) {
+ return new JDBCReaderStub(cfg, settings, revengStrategy);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List readDatabaseSchema(DefaultDatabaseCollectorStub dbs, String catalog, String
schema, ProgressListenerStub progress) {
+ return jdbcReader.readDatabaseSchema(dbs.defaultDatabaseCollector, catalog, schema,
progress.progressListener);
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JDBCToHibernateTypeHelperStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JDBCToHibernateTypeHelperStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JDBCToHibernateTypeHelperStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,25 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.cfg.reveng.JDBCToHibernateTypeHelper;
+
+public class JDBCToHibernateTypeHelperStub {
+
+ public static String getJDBCTypeName(int intValue) {
+ return JDBCToHibernateTypeHelper.getJDBCTypeName(intValue);
+ }
+
+ public static String getPreferredHibernateType(int intValue, int length, int precision,
+ int scale, boolean nullability, boolean b) {
+ return JDBCToHibernateTypeHelper.getPreferredHibernateType(intValue,
+ length, precision, scale, nullability, b);
+ }
+
+ public static boolean typeHasLength(int intValue) {
+ return JDBCToHibernateTypeHelper.typeHasLength(intValue);
+ }
+
+ public static boolean typeHasScaleAndPrecision(int intValue) {
+ return JDBCToHibernateTypeHelper.typeHasScaleAndPrecision(intValue);
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JoinStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JoinStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JoinStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,25 @@
+package org.hibernate.mediator.stubs;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.hibernate.mapping.Join;
+import org.hibernate.mapping.Property;
+
+public class JoinStub {
+ protected Join join;
+
+ protected JoinStub(Object join) {
+ this.join = (Join)join;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Iterator<PropertyStub> getPropertyIterator() {
+ Iterator<Property> it = (Iterator<Property>)join.getPropertyIterator();
+ ArrayList<PropertyStub> al = new ArrayList<PropertyStub>();
+ while (it.hasNext()) {
+ al.add(new PropertyStub(it.next()));
+ }
+ return al.iterator();
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JoinedSubclassStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JoinedSubclassStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/JoinedSubclassStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,26 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.JoinedSubclass;
+
+public class JoinedSubclassStub extends SubclassStub {
+
+ protected JoinedSubclass joinedSubclass;
+
+ protected JoinedSubclassStub(Object joinedSubclass) {
+ super(joinedSubclass);
+ this.joinedSubclass = (JoinedSubclass)joinedSubclass;
+ }
+
+ public static JoinedSubclassStub newInstance(PersistentClassStub persistentClass) {
+ return new JoinedSubclassStub(persistentClass);
+ }
+
+ public void setTable(TableStub table) {
+ joinedSubclass.setTable(table.getTable());
+ }
+
+ public void setKey(KeyValueStub key) {
+ joinedSubclass.setKey(key.keyValue);
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/KeyValueStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/KeyValueStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/KeyValueStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,16 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.KeyValue;
+
+public abstract class KeyValueStub extends ValueStub {
+ protected KeyValue keyValue;
+
+ protected KeyValueStub(Object keyValue) {
+ super(keyValue);
+ this.keyValue = (KeyValue)keyValue;
+ }
+
+ @Override
+ public abstract Object accept(ValueVisitorStub visitor);
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ListStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ListStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ListStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,26 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.List;
+
+public class ListStub extends IndexedCollectionStub {
+ protected List list;
+
+ protected ListStub(Object list) {
+ super(list);
+ this.list = (List)list;
+ }
+
+ public static ListStub newInstance(PersistentClassStub owner) {
+ return new ListStub(new List(owner.persistentClass));
+ }
+
+ @Override
+ public Object accept(ValueVisitorStub visitor) {
+ return visitor.accept(this);
+ }
+
+ public ValueStub getIndex() {
+ return ValueStubFactory.createValueStub(list.getIndex());
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ManyToOneStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ManyToOneStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ManyToOneStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,21 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.ManyToOne;
+
+public class ManyToOneStub extends ToOneStub {
+ protected ManyToOne manyToOne;
+
+ protected ManyToOneStub(Object manyToOne) {
+ super(manyToOne);
+ this.manyToOne = (ManyToOne)manyToOne;
+ }
+
+ public static ManyToOneStub newInstance(TableStub table) {
+ return new ManyToOneStub(new ManyToOne(table.table));
+ }
+
+ public String getReferencedEntityName() {
+ return manyToOne.getReferencedEntityName();
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/MapStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/MapStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/MapStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,21 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.Map;
+
+public class MapStub extends IndexedCollectionStub {
+ protected Map map;
+
+ protected MapStub(Object map) {
+ super(map);
+ this.map = (Map)map;
+ }
+
+ public static MapStub newInstance(PersistentClassStub owner) {
+ return new MapStub(new Map(owner.persistentClass));
+ }
+
+ @Override
+ public Object accept(ValueVisitorStub visitor) {
+ return visitor.accept(this);
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/MappingStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/MappingStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/MappingStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,11 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.engine.Mapping;
+
+public class MappingStub {
+ protected Mapping mapping;
+
+ protected MappingStub(Object mapping) {
+ this.mapping = (Mapping)mapping;
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/MappingsStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/MappingsStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/MappingsStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,15 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.cfg.Mappings;
+
+public class MappingsStub {
+ protected Mappings mappings;
+
+ protected MappingsStub(Object mappings) {
+ this.mappings = (Mappings)mappings;
+ }
+
+ public void addClass(PersistentClassStub persistentClass) {
+ mappings.addClass(persistentClass.getPersistentClass());
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/NamingStrategyStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/NamingStrategyStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/NamingStrategyStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,53 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.cfg.NamingStrategy;
+
+public class NamingStrategyStub {
+ protected NamingStrategy namingStrategy;
+
+ protected NamingStrategyStub(Object namingStrategy) {
+ this.namingStrategy = (NamingStrategy)namingStrategy;
+ }
+
+ @SuppressWarnings("nls")
+ public static String getClassName() {
+ return "org.hibernate.cfg.NamingStrategy";
+ }
+
+ public String classToTableName(String className) {
+ return namingStrategy.classToTableName(className);
+ }
+
+ public String tableName(String tableName) {
+ return namingStrategy.tableName(tableName);
+ }
+
+ public String columnName(String columnName) {
+ return namingStrategy.columnName(columnName);
+ }
+
+ public String propertyToColumnName(String propertyName) {
+ return namingStrategy.propertyToColumnName(propertyName);
+ }
+
+ public String joinKeyColumnName(String joinedColumn, String joinedTable) {
+ return namingStrategy.joinKeyColumnName(joinedColumn, joinedTable);
+ }
+
+ public String collectionTableName(String ownerEntity, String ownerEntityTable,
+ String associatedEntity, String associatedEntityTable,
+ String propertyName) {
+ return namingStrategy.collectionTableName(ownerEntity, ownerEntityTable,
+ associatedEntity, associatedEntityTable, propertyName);
+ }
+
+ public String logicalColumnName(String columnName, String propertyName) {
+ return namingStrategy.logicalColumnName(columnName, propertyName);
+ }
+
+ public String foreignKeyColumnName(String propertyName, String propertyEntityName,
+ String propertyTableName, String referencedColumnName) {
+ return namingStrategy.foreignKeyColumnName(propertyName,
+ propertyEntityName, propertyTableName, referencedColumnName);
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/NullableTypeStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/NullableTypeStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/NullableTypeStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,21 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.type.NullableType;
+
+public class NullableTypeStub extends AbstractTypeStub {
+
+ protected NullableType nullableType;
+
+ protected NullableTypeStub(Object nullableType) {
+ super(nullableType);
+ this.nullableType = (NullableType)nullableType;
+ }
+
+ public String toString(Object value) {
+ return nullableType.toString(value);
+ }
+
+ public Object fromStringValue(String xml) {
+ return nullableType.fromStringValue(xml);
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/OneToManyStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/OneToManyStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/OneToManyStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,36 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.OneToMany;
+
+public class OneToManyStub extends ValueStub {
+ protected OneToMany oneToMany;
+
+ protected OneToManyStub(Object oneToMany) {
+ super(oneToMany);
+ this.oneToMany = (OneToMany)oneToMany;
+ }
+
+ public static OneToManyStub newInstance(PersistentClassStub owner) {
+ return new OneToManyStub(new OneToMany(owner.persistentClass));
+ }
+
+ public void setAssociatedClass(PersistentClassStub associatedClass) {
+ oneToMany.setAssociatedClass(associatedClass.persistentClass);
+ }
+
+ public void setReferencedEntityName(String referencedEntityName) {
+ oneToMany.setReferencedEntityName(referencedEntityName);
+ }
+
+ public PersistentClassStub getAssociatedClass() {
+ return
PersistentClassStubFactory.createPersistentClassStub(oneToMany.getAssociatedClass());
+ }
+
+ public Object accept(ValueVisitorStub visitor) {
+ return visitor.accept(this);
+ }
+
+ public String getReferencedEntityName() {
+ return oneToMany.getReferencedEntityName();
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/OneToOneStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/OneToOneStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/OneToOneStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,21 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.OneToOne;
+
+public class OneToOneStub extends ToOneStub {
+ protected OneToOne oneToOne;
+
+ protected OneToOneStub(Object oneToOne) {
+ super(oneToOne);
+ this.oneToOne = (OneToOne)oneToOne;
+ }
+
+ public static OneToOneStub newInstance(TableStub table, PersistentClassStub owner) {
+ return new OneToOneStub(new OneToOne(table.table, owner.persistentClass));
+ }
+
+ public String getEntityName() {
+ return oneToOne.getEntityName();
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/OverrideRepositoryStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/OverrideRepositoryStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/OverrideRepositoryStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,21 @@
+package org.hibernate.mediator.stubs;
+
+import java.io.File;
+
+public class OverrideRepositoryStub {
+
+ public void addFile(File file) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public ReverseEngineeringStrategyStub getReverseEngineeringStrategy(
+ ReverseEngineeringStrategyStub res) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void addTableFilter(TableFilterStub tf) {
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/POJOClassStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/POJOClassStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/POJOClassStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,18 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.tool.hbm2x.pojo.POJOClass;
+
+public class POJOClassStub {
+
+ protected POJOClass pojoClass;
+
+ protected POJOClassStub(Object pojoClass) {
+ this.pojoClass = (POJOClass)pojoClass;
+ }
+
+ public String getQualifiedDeclarationName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PersistentClassStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PersistentClassStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PersistentClassStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,98 @@
+package org.hibernate.mediator.stubs;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.hibernate.mapping.Join;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Property;
+
+public abstract class PersistentClassStub {
+ protected PersistentClass persistentClass;
+
+ protected PersistentClassStub(Object persistentClass) {
+ this.persistentClass = (PersistentClass)persistentClass;
+ }
+
+ protected PersistentClass getPersistentClass() {
+ return persistentClass;
+ }
+
+ public Boolean isAbstract() {
+ return persistentClass.isAbstract();
+ }
+
+ public ValueStub getDiscriminator() {
+ return ValueStubFactory.createValueStub(persistentClass.getDiscriminator());
+ }
+
+ public String getClassName() {
+ return persistentClass.getClassName();
+ }
+
+ public String getEntityName() {
+ return persistentClass.getEntityName();
+ }
+
+ public PropertyStub getIdentifierProperty() {
+ return new PropertyStub(persistentClass.getIdentifierProperty());
+ }
+
+ @SuppressWarnings("unchecked")
+ public Iterator<PropertyStub> getPropertyIterator() {
+ Iterator<Property> it = persistentClass.getPropertyIterator();
+ ArrayList<PropertyStub> al = new ArrayList<PropertyStub>();
+ while (it.hasNext()) {
+ al.add(new PropertyStub(it.next()));
+ }
+ return al.iterator();
+ }
+
+ public RootClassStub getRootClass() {
+ return new RootClassStub(persistentClass.getRootClass());
+ }
+
+ public PropertyStub getVersion() {
+ return new PropertyStub(persistentClass.getVersion());
+ }
+
+ public TableStub getTable() {
+ return new TableStub(persistentClass.getTable());
+ }
+
+ @SuppressWarnings("unchecked")
+ public Iterator<JoinStub> getJoinIterator() {
+ Iterator<Join> it = (Iterator<Join>)persistentClass.getJoinIterator();
+ ArrayList<JoinStub> al = new ArrayList<JoinStub>();
+ while (it.hasNext()) {
+ al.add(new JoinStub(it.next()));
+ }
+ return al.iterator();
+ }
+
+ public KeyValueStub getIdentifier() {
+ return
(KeyValueStub)ValueStubFactory.createValueStub(persistentClass.getIdentifier());
+ }
+
+ public PersistentClassStub getSuperclass() {
+ return
PersistentClassStubFactory.createPersistentClassStub(persistentClass.getSuperclass());
+ }
+
+ public PropertyStub getProperty(String propertyName) {
+ return new PropertyStub(persistentClass.getProperty(propertyName));
+ }
+
+ public String getNodeName() {
+ return persistentClass.getNodeName();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Iterator<PropertyStub> getPropertyClosureIterator() {
+ Iterator<Property> it =
(Iterator<Property>)persistentClass.getPropertyClosureIterator();
+ ArrayList<PropertyStub> al = new ArrayList<PropertyStub>();
+ while (it.hasNext()) {
+ al.add(new PropertyStub(it.next()));
+ }
+ return al.iterator();
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PersistentClassStubFactory.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PersistentClassStubFactory.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PersistentClassStubFactory.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,26 @@
+package org.hibernate.mediator.stubs;
+
+public class PersistentClassStubFactory {
+ @SuppressWarnings("unchecked")
+ public static PersistentClassStub createPersistentClassStub(Object value) {
+ final Class cl = value.getClass();
+ if (0 == "org.hibernate.mapping.RootClass".compareTo(cl.getName())) {
//$NON-NLS-1$
+ return new RootClassStub(value);
+ //} else if (0 ==
"org.hibernate.mapping.PersistentClass".compareTo(cl.getName())) {
//$NON-NLS-1$
+ // return new PersistentClassStub(value);
+ } else if (0 == "org.hibernate.mapping.Subclass".compareTo(cl.getName())) {
//$NON-NLS-1$
+ return new SubclassStub(value);
+ } else if (0 ==
"org.hibernate.mapping.JoinedSubclass".compareTo(cl.getName())) { //$NON-NLS-1$
+ return new JoinedSubclassStub(value);
+ } else if (0 ==
"org.hibernate.mapping.SingleTableSubclass".compareTo(cl.getName())) {
//$NON-NLS-1$
+ return new SingleTableSubclassStub(value);
+ //} else if (0 ==
"org.hibernate.mapping.UnionSubclass".compareTo(cl.getName())) { //$NON-NLS-1$
+ // return new UnionSubclassStub(value);
+ }
+ return null;
+ }
+
+ public static PersistentClassStub createPersistentClassStub(PersistentClassStub value)
{
+ return createPersistentClassStub(value.persistentClass);
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PrimaryKeyStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PrimaryKeyStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PrimaryKeyStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,57 @@
+package org.hibernate.mediator.stubs;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.hibernate.mapping.Column;
+import org.hibernate.mapping.PrimaryKey;
+
+public class PrimaryKeyStub {
+ protected PrimaryKey primaryKey;
+
+ protected PrimaryKeyStub(Object primaryKey) {
+ this.primaryKey = (PrimaryKey)primaryKey;
+ }
+
+ public boolean containsColumn(ColumnStub column) {
+ return primaryKey.containsColumn(column.column);
+ }
+
+ public String getName() {
+ return primaryKey.getName();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Iterator<ColumnStub> columnIterator() {
+ Iterator<Column> it = (Iterator<Column>)primaryKey.getColumnIterator();
+ ArrayList<ColumnStub> al = new ArrayList<ColumnStub>();
+ while (it.hasNext()) {
+ al.add(new ColumnStub(it.next()));
+ }
+ return al.iterator();
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<ColumnStub> getColumns() {
+ Iterator<Column> it = (Iterator<Column>)primaryKey.getColumnIterator();
+ ArrayList<ColumnStub> al = new ArrayList<ColumnStub>();
+ while (it.hasNext()) {
+ al.add(new ColumnStub(it.next()));
+ }
+ return al;
+ }
+
+ public int getColumnSpan() {
+ return primaryKey.getColumnSpan();
+ }
+
+ public ColumnStub getColumn(int i) {
+ return new ColumnStub(primaryKey.getColumn(i));
+ }
+
+ public TableStub getTable() {
+ return new TableStub(primaryKey.getTable());
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PrimitiveArrayStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PrimitiveArrayStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PrimitiveArrayStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,21 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.PrimitiveArray;
+
+public class PrimitiveArrayStub extends ArrayStub {
+ protected PrimitiveArray primitiveArray;
+
+ protected PrimitiveArrayStub(Object primitiveArray) {
+ super(primitiveArray);
+ this.primitiveArray = (PrimitiveArray)primitiveArray;
+ }
+
+ public static PrimitiveArrayStub newInstance(PersistentClassStub owner) {
+ return new PrimitiveArrayStub(new PrimitiveArray(owner.persistentClass));
+ }
+
+ public void setElement(ValueStub element) {
+ primitiveArray.setElement(element.value);
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PrimitiveTypeStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PrimitiveTypeStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PrimitiveTypeStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,13 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.type.PrimitiveType;
+
+public class PrimitiveTypeStub extends ImmutableTypeStub {
+
+ protected PrimitiveType primitiveType;
+
+ protected PrimitiveTypeStub(Object primitiveType) {
+ super(primitiveType);
+ this.primitiveType = (PrimitiveType)primitiveType;
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ProgressListenerStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ProgressListenerStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ProgressListenerStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,19 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.cfg.reveng.ProgressListener;
+
+public abstract class ProgressListenerStub {
+
+ protected ProgressListener progressListener = new ProgressListener() {
+
+ public void startSubTask(String name) {
+ ProgressListenerStub.this.startSubTask(name);
+ }
+
+ };
+
+ protected ProgressListenerStub() {
+ }
+
+ public abstract void startSubTask(String name);
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PropertyStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PropertyStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/PropertyStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,96 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.Property;
+
+public class PropertyStub {
+ protected Property property;
+
+ protected PropertyStub(Object property) {
+ this.property = (Property)property;
+ }
+
+ public static PropertyStub newInstance() {
+ return new PropertyStub(new Property());
+ }
+
+ public void setName(String name) {
+ property.setName(name);
+ }
+
+ public void setValue(ValueStub value) {
+ property.setValue(value.value);
+ }
+
+ public ValueStub getValue() {
+ return ValueStubFactory.createValueStub(property.getValue());
+ }
+
+ public void setCascade(String cascade) {
+ property.setCascade(cascade);
+ }
+
+ public String getName() {
+ return property.getName();
+ }
+
+ public TypeStub getType() {
+ return TypeStubFactory.createTypeStub(property.getType());
+ }
+
+ public PersistentClassStub getPersistentClass() {
+ return
PersistentClassStubFactory.createPersistentClassStub(property.getPersistentClass());
+ }
+
+ public void setPersistentClass(PersistentClassStub ownerClass) {
+ property.setPersistentClass(ownerClass.persistentClass);
+ }
+
+ public boolean isSelectable() {
+ return property.isSelectable();
+ }
+
+ public boolean isInsertable() {
+ return property.isInsertable();
+ }
+
+ public boolean isUpdateable() {
+ return property.isUpdateable();
+ }
+
+ public boolean isLazy() {
+ return property.isLazy();
+ }
+
+ public boolean isOptional() {
+ return property.isOptional();
+ }
+
+ public boolean isNaturalIdentifier() {
+ return property.isNaturalIdentifier();
+ }
+
+ public boolean isOptimisticLocked() {
+ return property.isOptimisticLocked();
+ }
+
+ public String getCascade() {
+ return property.getCascade();
+ }
+
+ public String getNodeName() {
+ return property.getNodeName();
+ }
+
+ public boolean isBackRef() {
+ return property.isBackRef();
+ }
+
+ public boolean isComposite() {
+ return property.isComposite();
+ }
+
+ public String getPropertyAccessorName() {
+ return property.getPropertyAccessorName();
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ReverseEngineeringSettingsStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ReverseEngineeringSettingsStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ReverseEngineeringSettingsStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,37 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.cfg.reveng.ReverseEngineeringSettings;
+
+public class ReverseEngineeringSettingsStub {
+
+ protected ReverseEngineeringSettings reverseEngineeringSettings;
+
+ protected ReverseEngineeringSettingsStub(Object reverseEngineeringSettings) {
+ this.reverseEngineeringSettings =
(ReverseEngineeringSettings)reverseEngineeringSettings;
+ }
+
+ public static ReverseEngineeringSettingsStub newInstance(ReverseEngineeringStrategyStub
reverseEngineeringStrategy) {
+ return new ReverseEngineeringSettingsStub(new
ReverseEngineeringSettings(reverseEngineeringStrategy.reverseEngineeringStrategy));
+ }
+
+ public ReverseEngineeringSettingsStub setDefaultPackageName(String defaultPackageName)
{
+ reverseEngineeringSettings.setDefaultPackageName(defaultPackageName);
+ return this;
+ }
+
+ public ReverseEngineeringSettingsStub setDetectManyToMany(boolean b) {
+ reverseEngineeringSettings.setDetectManyToMany(b);
+ return this;
+ }
+
+ public ReverseEngineeringSettingsStub setDetectOneToOne(boolean b) {
+ reverseEngineeringSettings.setDetectOneToOne(b);
+ return this;
+ }
+
+ public ReverseEngineeringSettingsStub setDetectOptimisticLock(boolean
optimisticLockSupportEnabled) {
+ reverseEngineeringSettings.setDetectOptimisticLock(optimisticLockSupportEnabled);
+ return this;
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ReverseEngineeringStrategyStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ReverseEngineeringStrategyStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ReverseEngineeringStrategyStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,21 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.cfg.reveng.ReverseEngineeringStrategy;
+
+public class ReverseEngineeringStrategyStub {
+
+ protected ReverseEngineeringStrategy reverseEngineeringStrategy;
+
+ protected ReverseEngineeringStrategyStub(Object reverseEngineeringStrategy) {
+ this.reverseEngineeringStrategy =
(ReverseEngineeringStrategy)reverseEngineeringStrategy;
+ }
+
+ public static String getClassName() {
+ return ReverseEngineeringStrategy.class.getName();
+ }
+
+ public void setSettings(ReverseEngineeringSettingsStub qqsettings) {
+ // TODO Auto-generated method stub
+
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/RootClassStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/RootClassStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/RootClassStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,195 @@
+package org.hibernate.mediator.stubs;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.hibernate.mapping.RootClass;
+import org.hibernate.mapping.Subclass;
+
+public class RootClassStub extends PersistentClassStub {
+ protected RootClass rootClass;
+
+ protected RootClassStub(Object rootClass) {
+ super(rootClass);
+ this.rootClass = (RootClass)rootClass;
+ }
+
+ public static RootClassStub newInstance() {
+ return new RootClassStub(new RootClass());
+ }
+
+ public String getClassName() {
+ return rootClass.getClassName();
+ }
+
+ public void setDiscriminator(ValueStub discr) {
+ rootClass.setDiscriminator(discr.value);
+ }
+
+ public TableStub getTable() {
+ return new TableStub(rootClass.getTable());
+ }
+
+ public void addProperty(PropertyStub p) {
+ rootClass.addProperty(p.property);
+ }
+
+ public void setIdentifierProperty(PropertyStub p) {
+ rootClass.setIdentifierProperty(p.property);
+ }
+
+ public PropertyStub getIdentifierProperty() {
+ return new PropertyStub(rootClass.getIdentifierProperty());
+ }
+
+ public void setEntityName(String entityName) {
+ rootClass.setEntityName(entityName);
+ }
+
+ public void setClassName(String className) {
+ rootClass.setClassName(className);
+ }
+
+ public void setProxyInterfaceName(String proxyInterfaceName) {
+ rootClass.setProxyInterfaceName(proxyInterfaceName);
+ }
+
+ public void setLazy(boolean lazy) {
+ rootClass.setLazy(lazy);
+ }
+
+ public void setTable(TableStub table) {
+ rootClass.setTable(table.table);
+ }
+
+ public void setAbstract(Boolean isAbstract) {
+ rootClass.setAbstract(isAbstract);
+ }
+
+ public String getNodeName() {
+ return rootClass.getNodeName();
+ }
+
+ public KeyValueStub getIdentifier() {
+ return (KeyValueStub)ValueStubFactory.createValueStub(rootClass.getIdentifier());
+ }
+
+ public boolean isCustomDeleteCallable() {
+ return rootClass.isCustomDeleteCallable();
+ }
+
+ public boolean isCustomInsertCallable() {
+ return rootClass.isCustomInsertCallable();
+ }
+
+ public boolean isCustomUpdateCallable() {
+ return rootClass.isCustomUpdateCallable();
+ }
+
+ public boolean isDiscriminatorInsertable() {
+ return rootClass.isDiscriminatorInsertable();
+ }
+
+ public boolean isDiscriminatorValueNotNull() {
+ return rootClass.isDiscriminatorValueNotNull();
+ }
+
+ public boolean isDiscriminatorValueNull() {
+ return rootClass.isDiscriminatorValueNull();
+ }
+
+ public boolean isExplicitPolymorphism() {
+ return rootClass.isExplicitPolymorphism();
+ }
+
+ public boolean isForceDiscriminator() {
+ return rootClass.isForceDiscriminator();
+ }
+
+ public boolean isInherited() {
+ return rootClass.isInherited();
+ }
+
+ public boolean isJoinedSubclass() {
+ return rootClass.isJoinedSubclass();
+ }
+
+ public boolean isLazy() {
+ return rootClass.isLazy();
+ }
+
+ public boolean isLazyPropertiesCacheable() {
+ return rootClass.isLazyPropertiesCacheable();
+ }
+
+ public boolean isMutable() {
+ return rootClass.isMutable();
+ }
+
+ public boolean isPolymorphic() {
+ return rootClass.isPolymorphic();
+ }
+
+ public boolean isVersioned() {
+ return rootClass.isVersioned();
+ }
+
+ public int getBatchSize() {
+ return rootClass.getBatchSize();
+ }
+
+ public String getCacheConcurrencyStrategy() {
+ return rootClass.getCacheConcurrencyStrategy();
+ }
+
+ public String getCustomSQLDelete() {
+ return rootClass.getCustomSQLDelete();
+ }
+
+ public String getCustomSQLInsert() {
+ return rootClass.getCustomSQLInsert();
+ }
+
+ public String getCustomSQLUpdate() {
+ return rootClass.getCustomSQLUpdate();
+ }
+
+ public String getDiscriminatorValue() {
+ return rootClass.getDiscriminatorValue();
+ }
+
+ public String getLoaderName() {
+ return rootClass.getLoaderName();
+ }
+
+ public int getOptimisticLockMode() {
+ return rootClass.getOptimisticLockMode();
+ }
+
+ public String getTemporaryIdTableDDL() {
+ return rootClass.getTemporaryIdTableDDL();
+ }
+
+ public String getTemporaryIdTableName() {
+ return rootClass.getTemporaryIdTableName();
+ }
+
+ public String getWhere() {
+ return rootClass.getWhere();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Iterator<SubclassStub> getSubclassIterator() {
+ Iterator<Subclass> it =
(Iterator<Subclass>)rootClass.getSubclassIterator();
+ ArrayList<SubclassStub> al = new ArrayList<SubclassStub>();
+ while (it.hasNext()) {
+ al.add(new SubclassStub(it.next()));
+ }
+ return al.iterator();
+ }
+
+ @Override
+ public ValueStub getDiscriminator() {
+ return ValueStubFactory.createValueStub(rootClass.getDiscriminator());
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SQLTypeMappingStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SQLTypeMappingStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SQLTypeMappingStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,7 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.cfg.reveng.SQLTypeMapping;
+
+public class SQLTypeMappingStub {
+ public static final Boolean UNKNOWN_NULLABLE = SQLTypeMapping.UNKNOWN_NULLABLE;
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SessionStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SessionStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SessionStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,345 @@
+package org.hibernate.mediator.stubs;
+
+import java.sql.Time;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+import org.hibernate.Criteria;
+import org.hibernate.EntityMode;
+import org.hibernate.Session;
+import org.hibernate.Query;
+import org.hibernate.HibernateException;
+import org.hibernate.SessionFactory;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.mediator.Messages;
+import org.hibernate.mediator.ConsoleQueryParameter;
+import org.hibernate.mediator.QueryInputModel;
+import org.hibernate.mediator.util.CollectionPropertySource;
+import org.hibernate.metadata.ClassMetadata;
+import org.hibernate.metadata.CollectionMetadata;
+import org.hibernate.proxy.HibernateProxyHelper;
+import org.hibernate.type.Type;
+
+import bsh.EvalError;
+import bsh.Interpreter;
+
+public class SessionStub {
+
+ protected Session session;
+
+ protected SessionStub(Session session) {
+ this.session = session;
+ }
+
+ public boolean isOpen() {
+ boolean res = false;
+ if (session != null) {
+ res = session.isOpen();
+ }
+ return res;
+ }
+
+ public void close(List<Throwable> exceptions) {
+ if (session != null && session.isOpen()) {
+ try {
+ session.close();
+ } catch (HibernateException e) {
+ exceptions.add(e);
+ }
+ }
+ }
+
+ public boolean contains(Object obj) {
+ boolean res = false;
+ if (session != null) {
+ res = session.contains(obj);
+ }
+ return res;
+ }
+
+ public boolean hasMetaData(Object obj) {
+ boolean res = false;
+ if (session != null) {
+ res = session.getSessionFactory().getClassMetadata(
+ HibernateProxyHelper.getClassWithoutInitializingProxy(obj)) != null;
+ }
+ return res;
+ }
+
+ public boolean hasMetaData(Object obj, List<Throwable> exceptions) {
+ boolean res = false;
+ if (session != null) {
+ try {
+ res = session.getSessionFactory().getClassMetadata(
+ HibernateProxyHelper.getClassWithoutInitializingProxy(obj)) != null;
+ } catch (HibernateException e) {
+ exceptions.add(e);
+ }
+ }
+ return res;
+ }
+
+ public String getEntityName(Object obj) {
+ String res = null;
+ if (session != null) {
+ res = session.getEntityName(obj);
+ }
+ return res;
+ }
+
+ public String getEntityName(Object obj, List<Throwable> exceptions) {
+ String res = null;
+ if (session != null) {
+ try {
+ res = session.getEntityName(obj);
+ } catch (HibernateException e) {
+ exceptions.add(e);
+ }
+ }
+ return res;
+ }
+
+ public Object getPropertyValue(Object obj, Object id) {
+ Object pv = null;
+ if (session != null) {
+ SessionFactory sf = session.getSessionFactory();
+ ClassMetadata classMetadata;
+ if (session.isOpen()) {
+ classMetadata = sf.getClassMetadata(session.getEntityName(obj));
+ } else {
+ classMetadata = sf.getClassMetadata(HibernateProxyHelper
+ .getClassWithoutInitializingProxy(obj));
+ }
+ if (id.equals(classMetadata.getIdentifierPropertyName())) {
+ pv = classMetadata.getIdentifier(obj, EntityMode.POJO);
+ } else {
+ pv = classMetadata.getPropertyValue(obj, (String) id, EntityMode.POJO);
+ }
+ if (pv instanceof Collection<?>) {
+ CollectionMetadata collectionMetadata = sf.getCollectionMetadata(classMetadata
+ .getEntityName()
+ + "." + id); //$NON-NLS-1$
+ if (collectionMetadata != null) {
+ pv = new CollectionPropertySource((Collection<?>) pv);
+ }
+ }
+ }
+ return pv;
+ }
+
+ public IPropertyDescriptor[] getPropertyDescriptors(final Object obj) {
+ SessionFactory sf = session.getSessionFactory();
+ ClassMetadata classMetadata;
+ if (session.isOpen()) {
+ classMetadata = sf.getClassMetadata(session.getEntityName(obj));
+ } else {
+ classMetadata = sf.getClassMetadata(HibernateProxyHelper
+ .getClassWithoutInitializingProxy(obj));
+ }
+ return initializePropertyDescriptors(classMetadata);
+ }
+
+ protected IPropertyDescriptor[] initializePropertyDescriptors(ClassMetadata
classMetadata) {
+
+ String[] propertyNames = classMetadata.getPropertyNames();
+ int length = propertyNames.length;
+
+ PropertyDescriptor identifier = null;
+
+ if (classMetadata.hasIdentifierProperty()) {
+ identifier = new PropertyDescriptor(classMetadata.getIdentifierPropertyName(),
+ classMetadata.getIdentifierPropertyName());
+ identifier.setCategory(Messages.EntityPropertySource_identifier);
+ length++;
+ }
+
+ PropertyDescriptor[] properties = new PropertyDescriptor[length];
+
+ int idx = 0;
+ if (identifier != null) {
+ properties[idx++] = identifier;
+ }
+
+ for (int i = 0; i < propertyNames.length; i++) {
+ PropertyDescriptor prop = new PropertyDescriptor(propertyNames[i], propertyNames[i]);
+ prop.setCategory(Messages.EntityPropertySource_properties);
+ properties[i + idx] = prop;
+ }
+
+ return properties;
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<Object> evalCriteria(String criteriaCode, QueryInputModel model, Time
queryTime,
+ List<Throwable> exceptions) {
+ List<Object> res = Collections.emptyList();
+ if (criteriaCode.indexOf("System.exit") >= 0) { // TODO: externalize run
so we don't need this bogus check! //$NON-NLS-1$
+ exceptions.add(new IllegalArgumentException(Messages.JavaPage_not_allowed));
+ return res;
+ }
+ try {
+ Interpreter ip = setupInterpreter();
+ final Integer maxResults = model.getMaxResults();
+ long startTime = System.currentTimeMillis();
+ Object o = ip.eval(criteriaCode);
+ // ugly! TODO: make un-ugly!
+ if (o instanceof Criteria) {
+ Criteria criteria = (Criteria) o;
+ if (maxResults != null) {
+ criteria.setMaxResults(maxResults.intValue());
+ }
+ res = criteria.list();
+ } else if (o instanceof List<?>) {
+ res = (List<Object>) o;
+ if (maxResults != null) {
+ res = res.subList(0, Math.min(res.size(), maxResults.intValue()));
+ }
+ } else {
+ res = new ArrayList<Object>();
+ res.add(o);
+ }
+ queryTime.setTime(System.currentTimeMillis() - startTime);
+ } catch (EvalError e) {
+ exceptions.add(e);
+ } catch (HibernateException e) {
+ exceptions.add(e);
+ }
+ return res;
+ }
+
+ @SuppressWarnings("unchecked")
+ private Interpreter setupInterpreter() throws EvalError, HibernateException {
+ Interpreter interpreter = new Interpreter();
+
+ interpreter.set("session", session); //$NON-NLS-1$
+ interpreter.setClassLoader(Thread.currentThread().getContextClassLoader());
+ SessionImplementor si = (SessionImplementor) session;
+
+ Map<String, ?> map = si.getFactory().getAllClassMetadata();
+
+ Iterator<String> iterator = map.keySet().iterator();
+ // TODO: filter non classes.
+ String imports = ""; //$NON-NLS-1$
+ while (iterator.hasNext()) {
+ String element = iterator.next();
+ imports += "import " + element + ";\n"; //$NON-NLS-1$
//$NON-NLS-2$
+ }
+
+ imports += "import org.hibernate.criterion.*;\n"; //$NON-NLS-1$
+ imports += "import org.hibernate.*;\n"; //$NON-NLS-1$
+ // TODO: expose the parameters as values to be used in the code.
+ interpreter.eval(imports);
+
+ return interpreter;
+ }
+
+ public List<Object> evalQuery(String queryString, QueryInputModel model, Time
queryTime,
+ List<Throwable> exceptions) {
+ List<Object> res = Collections.emptyList();
+ Query query = null;
+ try {
+ query = session.createQuery(queryString);
+ } catch (HibernateException e) {
+ exceptions.add(e);
+ } catch (Exception e) {
+ exceptions.add(e);
+ }
+ if (query == null) {
+ return res;
+ }
+ try {
+ res = new ArrayList<Object>();
+ setupParameters(query, model);
+ long startTime = System.currentTimeMillis();
+ // need to be user-controllable to toggle between iterate, scroll etc.
+ Iterator<?> iter = query.list().iterator();
+ queryTime.setTime(System.currentTimeMillis() - startTime);
+ while (iter.hasNext()) {
+ Object element = iter.next();
+ res.add(element);
+ }
+ } catch (HibernateException e) {
+ exceptions.add(e);
+ } catch (IllegalArgumentException e) {
+ exceptions.add(e);
+ }
+ return res;
+ }
+
+ private void setupParameters(Query query, QueryInputModel model) {
+ if (model.getMaxResults() != null) {
+ query.setMaxResults(model.getMaxResults().intValue());
+ }
+ ConsoleQueryParameter[] qp = model.getQueryParameters();
+ for (int i = 0; i < qp.length; i++) {
+ ConsoleQueryParameter parameter = qp[i];
+ try {
+ int pos = Integer.parseInt(parameter.getName());
+ query.setParameter(pos, calcValue(parameter), parameter.getType().type);
+ } catch (NumberFormatException nfe) {
+ query.setParameter(parameter.getName(), calcValue(parameter),
parameter.getType().type);
+ }
+ }
+ }
+
+ private Object calcValue(ConsoleQueryParameter parameter) {
+ return parameter.getValueForQuery();
+ }
+
+ public List<String> evalQueryPathNames(String queryString, QueryInputModel model,
+ List<Throwable> exceptions) {
+ List<String> res = Collections.emptyList();
+ Query query = null;
+ try {
+ query = session.createQuery(queryString);
+ } catch (HibernateException e) {
+ exceptions.add(e);
+ } catch (Exception e) {
+ exceptions.add(e);
+ }
+ if (query == null) {
+ return res;
+ }
+ try {
+ String[] returnAliases = null;
+ try {
+ returnAliases = query.getReturnAliases();
+ } catch (NullPointerException e) {
+ // ignore -
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2188
+ }
+ if (returnAliases == null) {
+ Type[] t;
+ try {
+ t = query.getReturnTypes();
+ } catch (NullPointerException npe) {
+ t = new Type[] { null };
+ // ignore -
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2188
+ }
+ res = new ArrayList<String>(t.length);
+ for (int i = 0; i < t.length; i++) {
+ Type type = t[i];
+ if (type == null) {
+ res.add("<multiple types>"); //$NON-NLS-1$
+ } else {
+ res.add(type.getName());
+ }
+ }
+ } else {
+ String[] t = returnAliases;
+ res = new ArrayList<String>(t.length);
+ for (int i = 0; i < t.length; i++) {
+ res.add(t[i]);
+ }
+ }
+ } catch (HibernateException e) {
+ exceptions.add(e);
+ }
+ return res;
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SessionStubFactory.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SessionStubFactory.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SessionStubFactory.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,164 @@
+package org.hibernate.mediator.stubs;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.engine.query.HQLQueryPlan;
+import org.hibernate.hql.QueryTranslator;
+import org.hibernate.impl.SessionFactoryImpl;
+import org.hibernate.mediator.Messages;
+import org.hibernate.mediator.util.ELTransformer;
+import org.hibernate.mediator.util.QLFormatHelper;
+import org.hibernate.metadata.ClassMetadata;
+import org.hibernate.metadata.CollectionMetadata;
+import org.hibernate.type.Type;
+
+public class SessionStubFactory {
+
+ protected SessionFactory sessionFactory;
+
+ public SessionStubFactory(ConfigurationStub configStub) {
+ sessionFactory = configStub.buildSessionFactory();
+ }
+
+ public boolean isSessionFactoryCreated() {
+ return sessionFactory != null;
+ }
+
+ public SessionStub openSession() {
+ if (sessionFactory != null) {
+ return new SessionStub(sessionFactory.openSession());
+ }
+ return null;
+ }
+
+ public void close() {
+ if (sessionFactory != null) {
+ sessionFactory.close();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<String> getClasses() {
+ List<String> res = Collections.emptyList();
+ if (sessionFactory != null) {
+ res = new ArrayList<String>();
+ res.addAll(sessionFactory.getAllClassMetadata().keySet());
+ }
+ return res;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Map<String, ClassMetadataStub> getClassMetaData() {
+ if (sessionFactory == null) {
+ return new HashMap<String, ClassMetadataStub>();
+ }
+ Map<String, ClassMetadata> allClassMetadata =
sessionFactory.getAllClassMetadata();
+ Iterator<Map.Entry<String, ClassMetadata>> it =
allClassMetadata.entrySet().iterator();
+ Map<String, ClassMetadataStub> res = new HashMap<String,
ClassMetadataStub>();
+ while (it.hasNext()) {
+ Map.Entry<String, ClassMetadata> entry = it.next();
+ res.put(entry.getKey(), new ClassMetadataStub(entry.getValue()));
+ }
+ return res;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Map<String, CollectionMetadataStub> getCollectionMetaData() {
+ if (sessionFactory == null) {
+ return new HashMap<String, CollectionMetadataStub>();
+ }
+ Map<String, CollectionMetadata> allClassMetadata =
sessionFactory.getAllCollectionMetadata();
+ Iterator<Map.Entry<String, CollectionMetadata>> it =
allClassMetadata.entrySet().iterator();
+ Map<String, CollectionMetadataStub> res = new HashMap<String,
CollectionMetadataStub>();
+ while (it.hasNext()) {
+ Map.Entry<String, CollectionMetadata> entry = it.next();
+ res.put(entry.getKey(), new CollectionMetadataStub(entry.getValue()));
+ }
+ return res;
+ }
+
+ /**
+ * Given a ConsoleConfiguration and a query this method validates the query through
hibernate if
+ * a sessionfactory is available.
+ *
+ * @param query
+ * @param allowEL
+ * if true, EL syntax will be replaced as a named variable
+ */
+ public void checkQuery(String query, boolean allowEL) {
+ if (sessionFactory != null) {
+ if (allowEL) {
+ query = ELTransformer.removeEL(query);
+ }
+ new HQLQueryPlan(query, false, Collections.EMPTY_MAP,
+ (SessionFactoryImpl) sessionFactory);
+ }
+ }
+
+ public String generateSQL(String query) {
+ try {
+ SessionFactoryImpl sfimpl = (SessionFactoryImpl) sessionFactory; // hack - to get to
the
+ // actual queries..
+ StringBuffer str = new StringBuffer(256);
+ HQLQueryPlan plan = new HQLQueryPlan(query, false, Collections.EMPTY_MAP, sfimpl);
+
+ QueryTranslator[] translators = plan.getTranslators();
+ for (int i = 0; i < translators.length; i++) {
+ QueryTranslator translator = translators[i];
+ if (translator.isManipulationStatement()) {
+ str.append(Messages.DynamicSQLPreviewView_manipulation_of + i
+ + ":"); //$NON-NLS-1$
+ Iterator<?> iterator = translator.getQuerySpaces().iterator();
+ while (iterator.hasNext()) {
+ Object qspace = iterator.next();
+ str.append(qspace);
+ if (iterator.hasNext()) {
+ str.append(", ");} //$NON-NLS-1$
+ }
+
+ } else {
+ Type[] returnTypes = translator.getReturnTypes();
+ str.append(i + ": "); //$NON-NLS-1$
+ for (int j = 0; j < returnTypes.length; j++) {
+ Type returnType = returnTypes[j];
+ str.append(returnType.getName());
+ if (j < returnTypes.length - 1) {
+ str.append(", ");} //$NON-NLS-1$
+ }
+ }
+ str.append("\n-----------------\n"); //$NON-NLS-1$
+ Iterator<?> sqls = translator.collectSqlStrings().iterator();
+ while (sqls.hasNext()) {
+ String sql = (String) sqls.next();
+ str.append(QLFormatHelper.formatForScreen(sql));
+ str.append("\n\n"); //$NON-NLS-1$
+ }
+ }
+ return str.toString();
+ } catch (Throwable t) {
+ // StringWriter sw = new StringWriter();
+ StringBuffer msgs = new StringBuffer();
+
+ Throwable cause = t;
+ while (cause != null) {
+ msgs.append(t);
+ if (cause.getCause() == cause) {
+ cause = null;
+ } else {
+ cause = cause.getCause();
+ if (cause != null)
+ msgs.append(Messages.DynamicSQLPreviewView_caused_by);
+ }
+ }
+ // t.printStackTrace(new PrintWriter(sw));
+ // return sw.getBuffer().toString();
+ return msgs.toString();
+ }
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SetStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SetStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SetStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,22 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.Set;
+
+public class SetStub extends CollectionStub {
+ protected Set set;
+
+ protected SetStub(Object set) {
+ super(set);
+ this.set = (Set)set;
+ }
+
+ public static SetStub newInstance(PersistentClassStub owner) {
+ return new SetStub(new Set(owner.persistentClass));
+ }
+
+ @Override
+ public Object accept(ValueVisitorStub visitor) {
+ return visitor.accept(this);
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SettingsStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SettingsStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SettingsStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,23 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.cfg.Settings;
+
+public class SettingsStub {
+ protected Settings settings;
+
+ protected SettingsStub(Object settings) {
+ this.settings = (Settings)settings;
+ }
+
+ public ConnectionProviderStub getConnectionProvider() {
+ return new ConnectionProviderStub(settings.getConnectionProvider());
+ }
+
+ public String getDefaultCatalogName() {
+ return settings.getDefaultCatalogName();
+ }
+
+ public String getDefaultSchemaName() {
+ return settings.getDefaultSchemaName();
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SimpleValueStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SimpleValueStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SimpleValueStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,52 @@
+package org.hibernate.mediator.stubs;
+
+import java.util.Properties;
+
+import org.hibernate.mapping.SimpleValue;
+
+public class SimpleValueStub extends KeyValueStub {
+
+ protected SimpleValue simpleValue;
+
+ protected SimpleValueStub(Object simpleValue) {
+ super(simpleValue);
+ this.simpleValue = (SimpleValue)simpleValue;
+ }
+
+ public static SimpleValueStub newInstance() {
+ return new SimpleValueStub(new SimpleValue());
+ }
+
+ public void setTypeName(String type) {
+ simpleValue.setTypeName(type);
+ }
+
+ public void addColumn(ColumnStub column) {
+ simpleValue.addColumn(column.column);
+ }
+
+ public void setTable(TableStub table) {
+ simpleValue.setTable(table.table);
+ }
+
+ public void setTypeParameters(Properties parameterMap) {
+ simpleValue.setTypeParameters(parameterMap);
+ }
+
+ public String getForeignKeyName() {
+ return simpleValue.getForeignKeyName();
+ }
+
+ public String getTypeName() {
+ return simpleValue.getTypeName();
+ }
+
+ public boolean isTypeSpecified() {
+ return simpleValue.isTypeSpecified();
+ }
+
+ @Override
+ public Object accept(ValueVisitorStub visitor) {
+ return visitor.accept(this);
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SingleTableSubclassStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SingleTableSubclassStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SingleTableSubclassStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,17 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.SingleTableSubclass;
+
+public class SingleTableSubclassStub extends SubclassStub {
+ protected SingleTableSubclass singleTableSubclass;
+
+ protected SingleTableSubclassStub(Object singleTableSubclass) {
+ super(singleTableSubclass);
+ this.singleTableSubclass = (SingleTableSubclass)singleTableSubclass;
+ }
+
+ public static SingleTableSubclassStub newInstance(Object singleTableSubclass) {
+ return new SingleTableSubclassStub(singleTableSubclass);
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SubclassStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SubclassStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SubclassStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,41 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mapping.Subclass;
+
+public class SubclassStub extends PersistentClassStub {
+
+ protected Subclass subclass;
+
+ protected SubclassStub(Object subclass) {
+ super(subclass);
+ this.subclass = (Subclass)subclass;
+ }
+
+ public void setClassName(String className) {
+ subclass.setClassName(className);
+ }
+
+ public void setEntityName(String entityName) {
+ subclass.setEntityName(entityName);
+ }
+
+ public void setDiscriminatorValue(String discriminatorValue) {
+ subclass.setDiscriminatorValue(discriminatorValue);
+ }
+
+ public void setAbstract(Boolean isAbstract) {
+ subclass.setAbstract(isAbstract);
+ }
+
+ public void addProperty(PropertyStub p) {
+ subclass.addProperty(p.property);
+ }
+
+ public TableStub getRootTable() {
+ return new TableStub(subclass.getRootTable());
+ }
+
+ public boolean isJoinedSubclass() {
+ return subclass.isJoinedSubclass();
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TableFilterStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TableFilterStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TableFilterStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,45 @@
+package org.hibernate.mediator.stubs;
+
+public class TableFilterStub {
+
+ public void setExclude(Boolean exclude) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setMatchCatalog(String matchCatalog) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setMatchName(String matchName) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setMatchSchema(String matchSchema) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Boolean getExclude() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getMatchCatalog() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getMatchSchema() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getMatchName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TableIdentifierStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TableIdentifierStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TableIdentifierStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,23 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.cfg.reveng.TableIdentifier;
+
+public class TableIdentifierStub {
+ protected TableIdentifier tableIdentifier;
+
+ protected TableIdentifierStub(Object tableIdentifier) {
+ this.tableIdentifier = (TableIdentifier)tableIdentifier;
+ }
+
+ public static TableIdentifierStub create(TableStub table) {
+ return newInstance(table.getCatalog(), table.getSchema(), table.getName() );
+ }
+
+ public static TableIdentifierStub newInstance(String catalog, String schema, String
name) {
+ return new TableIdentifierStub(new TableIdentifier(catalog, schema, name));
+ }
+
+ public String getName() {
+ return tableIdentifier.getName();
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TableStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TableStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TableStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,92 @@
+package org.hibernate.mediator.stubs;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.hibernate.mapping.Column;
+import org.hibernate.mapping.ForeignKey;
+import org.hibernate.mapping.Table;
+
+public class TableStub {
+ protected Table table;
+
+ protected TableStub(Object table) {
+ this.table = (Table)table;
+ }
+
+ protected Table getTable() {
+ return table;
+ }
+
+ public static TableStub newInstance(String name) {
+ return new TableStub(new Table(name));
+ }
+
+ public String getName() {
+ return table.getName();
+ }
+
+ public PrimaryKeyStub getPrimaryKey() {
+ return new PrimaryKeyStub(table.getPrimaryKey());
+ }
+
+ @SuppressWarnings("unchecked")
+ public Iterator<ForeignKeyStub> getForeignKeyIterator() {
+ Iterator<ForeignKey> it =
(Iterator<ForeignKey>)table.getForeignKeyIterator();
+ ArrayList<ForeignKeyStub> al = new ArrayList<ForeignKeyStub>();
+ while (it.hasNext()) {
+ al.add(new ForeignKeyStub(it.next()));
+ }
+ return al.iterator();
+ }
+
+ public String getCatalog() {
+ return table.getCatalog();
+ }
+
+ public String getSchema() {
+ return table.getSchema();
+ }
+
+ public DependantValueStub getIdentifierValue() {
+ return new DependantValueStub(table.getIdentifierValue());
+ }
+
+ @SuppressWarnings("unchecked")
+ public Iterator<ColumnStub> getColumnIterator() {
+ Iterator<Column> it = (Iterator<Column>)table.getColumnIterator();
+ ArrayList<ColumnStub> al = new ArrayList<ColumnStub>();
+ while (it.hasNext()) {
+ al.add(new ColumnStub(it.next()));
+ }
+ return al.iterator();
+ }
+
+ public String getComment() {
+ return table.getComment();
+ }
+
+ public String getRowId() {
+ return table.getRowId();
+ }
+
+ public String getSubselect() {
+ return table.getSubselect();
+ }
+
+ public boolean hasDenormalizedTables() {
+ return table.hasDenormalizedTables();
+ }
+
+ public boolean isAbstract() {
+ return table.isAbstract();
+ }
+
+ public boolean isAbstractUnionTable() {
+ return table.isAbstractUnionTable();
+ }
+
+ public boolean isPhysicalTable() {
+ return table.isPhysicalTable();
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ToOneStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ToOneStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ToOneStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,36 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.FetchMode;
+import org.hibernate.mapping.ToOne;
+
+public class ToOneStub extends SimpleValueStub {
+ protected ToOne toOne;
+
+ protected ToOneStub(Object toOne) {
+ super(toOne);
+ this.toOne = (ToOne)toOne;
+ }
+
+ public void setReferencedEntityName(String referencedEntityName) {
+ toOne.setReferencedEntityName(referencedEntityName);
+ }
+
+ public void setReferencedPropertyName(String name) {
+ toOne.setReferencedPropertyName(name);
+ }
+
+ public void setFetchMode(FetchModeStub fetchMode) {
+ if (FetchModeStub.DEFAULT.equals(fetchMode)) {
+ toOne.setFetchMode(FetchMode.DEFAULT);
+ } else if (FetchModeStub.SELECT.equals(fetchMode)) {
+ toOne.setFetchMode(FetchMode.SELECT);
+ } else if (FetchModeStub.JOIN.equals(fetchMode)) {
+ toOne.setFetchMode(FetchMode.JOIN);
+ } else if (FetchModeStub.SUBSELECT.equals(fetchMode)) {
+ }
+ }
+
+ public boolean isEmbedded() {
+ return toOne.isEmbedded();
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TypeStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TypeStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TypeStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,36 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.type.Type;
+
+public abstract class TypeStub {
+ protected Type type;
+
+ protected TypeStub(Object type) {
+ this.type = (Type)type;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Class getReturnedClass() {
+ return type.getReturnedClass();
+ }
+
+ public boolean isCollectionType() {
+ return type.isCollectionType();
+ }
+
+ public boolean isEntityType() {
+ return type.isEntityType();
+ }
+
+ public boolean isAnyType() {
+ return type.isAnyType();
+ }
+
+ public boolean isComponentType() {
+ return type.isComponentType();
+ }
+
+ public String getName() {
+ return type.getName();
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TypeStubFactory.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TypeStubFactory.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TypeStubFactory.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,34 @@
+package org.hibernate.mediator.stubs;
+
+import java.lang.reflect.Type;
+
+public class TypeStubFactory {
+ @SuppressWarnings("unchecked")
+ public static TypeStub createTypeStub(Object value) {
+ final Class cl = value.getClass();
+ if (isClassOrOffspring(cl, "org.hibernate.type.CollectionType")) {
//$NON-NLS-1$
+ return new CollectionTypeStub(value);
+ //} else if (0 == "org.hibernate.type.Type".compareTo(cl.getName())) {
//$NON-NLS-1$
+ // return new TypeStub(value);
+ } else if (isClassOrOffspring(cl, "org.hibernate.type.EntityType")) {
//$NON-NLS-1$
+ return new EntityTypeStub(value);
+ } else if (isClassOrOffspring(cl, "org.hibernate.type.NullableType")) {
//$NON-NLS-1$
+ return new NullableTypeStub(value);
+ }
+ return new AbstractTypeStub(value);
+ }
+
+ protected static boolean isClassOrOffspring(final Class<?> cl, final String name)
{
+ if (cl == null || name == null) {
+ return false;
+ }
+ if (0 == name.compareTo(cl.getName())) {
+ return true;
+ }
+ Type type = cl.getGenericSuperclass();
+ if (type instanceof Class<?>) {
+ return isClassOrOffspring((Class<?>)type, name);
+ }
+ return false;
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ValueStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ValueStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ValueStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,39 @@
+package org.hibernate.mediator.stubs;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.hibernate.mapping.Column;
+import org.hibernate.mapping.Value;
+
+public abstract class ValueStub {
+ protected Value value;
+
+ protected ValueStub(Object value) {
+ this.value = (Value)value;
+ }
+
+ public TableStub getTable() {
+ return new TableStub(value.getTable());
+ }
+
+ public boolean isSimpleValue() {
+ return value.isSimpleValue();
+ }
+
+ public TypeStub getType() {
+ return TypeStubFactory.createTypeStub(value.getType());
+ }
+
+ @SuppressWarnings("unchecked")
+ public Iterator<ColumnStub> getColumnIterator() {
+ Iterator<Column> it = (Iterator<Column>)value.getColumnIterator();
+ ArrayList<ColumnStub> al = new ArrayList<ColumnStub>();
+ while (it.hasNext()) {
+ al.add(new ColumnStub(it.next()));
+ }
+ return al.iterator();
+ }
+
+ public abstract Object accept(ValueVisitorStub visitor);
+};
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ValueStubFactory.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ValueStubFactory.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ValueStubFactory.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,46 @@
+package org.hibernate.mediator.stubs;
+
+public class ValueStubFactory {
+ @SuppressWarnings("unchecked")
+ public static ValueStub createValueStub(Object value) {
+ final Class cl = value.getClass();
+ if (0 == "org.hibernate.mapping.Bag".compareTo(cl.getName())) {
//$NON-NLS-1$
+ return new BagStub(value);
+ //} else if (0 ==
"org.hibernate.mapping.IdentifierCollection".compareTo(cl.getName())) {
//$NON-NLS-1$
+ // return new IdentifierCollectionStub(value);
+ } else if (0 ==
"org.hibernate.mapping.IdentifierBag".compareTo(cl.getName())) { //$NON-NLS-1$
+ return new IdentifierBagStub(value);
+ //} else if (0 ==
"org.hibernate.mapping.IndexedCollection".compareTo(cl.getName())) {
//$NON-NLS-1$
+ // return new IndexedCollectionStub(value);
+ } else if (0 == "org.hibernate.mapping.List".compareTo(cl.getName())) {
//$NON-NLS-1$
+ return new ListStub(value);
+ } else if (0 == "org.hibernate.mapping.Array".compareTo(cl.getName())) {
//$NON-NLS-1$
+ return new ArrayStub(value);
+ } else if (0 ==
"org.hibernate.mapping.PrimitiveArray".compareTo(cl.getName())) { //$NON-NLS-1$
+ return new PrimitiveArrayStub(value);
+ } else if (0 == "org.hibernate.mapping.Map".compareTo(cl.getName())) {
//$NON-NLS-1$
+ return new MapStub(value);
+ } else if (0 == "org.hibernate.mapping.Set".compareTo(cl.getName())) {
//$NON-NLS-1$
+ return new SetStub(value);
+ } else if (0 == "org.hibernate.mapping.OneToMany".compareTo(cl.getName())) {
//$NON-NLS-1$
+ return new OneToManyStub(value);
+ //} else if (0 == "org.hibernate.mapping.KeyValue".compareTo(cl.getName())) {
//$NON-NLS-1$
+ // return new KeyValueStub(value);
+ } else if (0 == "org.hibernate.mapping.SimpleValue".compareTo(cl.getName()))
{ //$NON-NLS-1$
+ return new SimpleValueStub(value);
+ } else if (0 == "org.hibernate.mapping.Any".compareTo(cl.getName())) {
//$NON-NLS-1$
+ return new AnyStub(value);
+ } else if (0 == "org.hibernate.mapping.Component".compareTo(cl.getName())) {
//$NON-NLS-1$
+ return new ComponentStub(value);
+ } else if (0 ==
"org.hibernate.mapping.DependantValue".compareTo(cl.getName())) { //$NON-NLS-1$
+ return new DependantValueStub(value);
+ } else if (0 == "org.hibernate.mapping.ToOne".compareTo(cl.getName())) {
//$NON-NLS-1$
+ return new ToOneStub(value);
+ } else if (0 == "org.hibernate.mapping.ManyToOne".compareTo(cl.getName())) {
//$NON-NLS-1$
+ return new ManyToOneStub(value);
+ } else if (0 == "org.hibernate.mapping.OneToOne".compareTo(cl.getName())) {
//$NON-NLS-1$
+ return new OneToOneStub(value);
+ }
+ return null;
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ValueVisitorStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ValueVisitorStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ValueVisitorStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,19 @@
+package org.hibernate.mediator.stubs;
+
+// look at org.hibernate.mapping.ValueVisitor
+public interface ValueVisitorStub {
+ Object accept(BagStub bag);
+ Object accept(IdentifierBagStub bag);
+ Object accept(ListStub list);
+ Object accept(PrimitiveArrayStub primitiveArray);
+ Object accept(ArrayStub list);
+ Object accept(MapStub map);
+ Object accept(OneToManyStub many);
+ Object accept(SetStub set);
+ Object accept(AnyStub any);
+ Object accept(SimpleValueStub value);
+ Object accept(DependantValueStub value);
+ Object accept(ComponentStub component);
+ Object accept(ManyToOneStub mto);
+ Object accept(OneToOneStub oto);
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/XMLPrettyPrinterStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/XMLPrettyPrinterStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/XMLPrettyPrinterStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,15 @@
+package org.hibernate.mediator.stubs;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.hibernate.tool.hbm2x.XMLPrettyPrinter;
+
+public class XMLPrettyPrinterStub {
+
+ public static void prettyPrint(InputStream in, OutputStream writer) throws IOException
{
+ XMLPrettyPrinter.prettyPrint(in, writer);
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/CollectionHelper.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/CollectionHelper.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/CollectionHelper.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,32 @@
+package org.hibernate.mediator.stubs.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@SuppressWarnings("unchecked")
+public final class CollectionHelper {
+
+ public static final List EMPTY_LIST = Collections.unmodifiableList( new ArrayList(0) );
+ public static final Collection EMPTY_COLLECTION = Collections.unmodifiableCollection(
new ArrayList(0) );
+ public static final Map EMPTY_MAP = Collections.unmodifiableMap( new HashMap(0) );
+
+ private CollectionHelper() {
+ }
+
+ /**
+ * Build a properly sized map, especially handling load size and load factor to prevent
immediate resizing.
+ * <p/>
+ * Especially helpful for copy map contents.
+ *
+ * @param size The size to make the map.
+ * @return The sized map.
+ */
+ public static Map mapOfSize(int size) {
+ final int currentSize = (int) (size / 0.75f);
+ return new HashMap( Math.max( currentSize+ 1, 16), 0.75f );
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/HqlBaseLexerStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/HqlBaseLexerStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/HqlBaseLexerStub.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,39 @@
+package org.hibernate.mediator.stubs.util;
+
+import java.io.Reader;
+
+import org.hibernate.hql.antlr.HqlBaseLexer;
+import org.hibernate.mediator.stubs.HqlSqlTokenTypesStub;
+
+import antlr.Token;
+import antlr.TokenStreamException;
+
+public class HqlBaseLexerStub {
+
+ protected HqlBaseLexer hqlBaseLexer;
+
+ protected HqlBaseLexerStub(HqlBaseLexer hqlBaseLexer) {
+ this.hqlBaseLexer = hqlBaseLexer;
+ }
+
+ public static HqlBaseLexerStub newInstance(Reader in) {
+ return new HqlBaseLexerStub(new HqlBaseLexer(in));
+ }
+
+ private Token nextToken() {
+ try {
+ return hqlBaseLexer.nextToken();
+ } catch (TokenStreamException e) {
+ return null;
+ }
+ }
+
+ public boolean isNextTokenIdent() {
+ Token token = nextToken();
+ if (token != null && token.getType() == HqlSqlTokenTypesStub.IDENT) {
+ return true;
+ }
+ return false;
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/OpenMappingUtilsEjb3.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/OpenMappingUtilsEjb3.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/OpenMappingUtilsEjb3.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,282 @@
+package org.hibernate.mediator.stubs.util;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import javax.persistence.Embeddable;
+import javax.persistence.Entity;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.spi.PersistenceUnitTransactionType;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import org.hibernate.ejb.HibernatePersistence;
+import org.hibernate.ejb.packaging.ClassFilter;
+import org.hibernate.ejb.packaging.Entry;
+import org.hibernate.ejb.packaging.FileFilter;
+import org.hibernate.ejb.packaging.Filter;
+import org.hibernate.ejb.packaging.JarVisitor;
+import org.hibernate.ejb.packaging.JarVisitorFactory;
+import org.hibernate.ejb.packaging.NamedInputStream;
+import org.hibernate.ejb.packaging.PackageFilter;
+import org.hibernate.ejb.packaging.PersistenceMetadata;
+import org.hibernate.ejb.packaging.PersistenceXmlLoader;
+import org.hibernate.mediator.stubs.util.CollectionHelper;
+import org.xml.sax.EntityResolver;
+
+/**
+ * Most functions in this utility class are copy of
+ * org.hibernate.ejb.Ejb3Configuration private functions.
+ * These functions are responsible for bypass all ejb3 configuration files.
+ *
+ * @author Vitali Yemialyanchyk
+ */
+public class OpenMappingUtilsEjb3 {
+
+ public static final String META_INF_PERS_XML = "META-INF/persistence.xml";
//$NON-NLS-1$
+ public static final String META_INF_ORM_XML = "META-INF/orm.xml";
//$NON-NLS-1$
+
+ private OpenMappingUtilsEjb3() {}
+
+ /**
+ * Collect list of paths to ejb3 resource configuration files.
+ * This function code based on code from Ejb3Configuration.
+ * @see Ejb3Configuration configure(String persistenceUnitName, Map integration)
+ *
+ * @param consoleConfiguration
+ * @return
+ */
+ public static List<String> enumDocuments(String persistenceUnitName,
EntityResolver er) {
+ Enumeration<URL> xmls = null;
+ try {
+ xmls =
Thread.currentThread().getContextClassLoader().getResources(META_INF_PERS_XML);
+ } catch (IOException e) {
+ //ignore
+ }
+ if (xmls == null || !xmls.hasMoreElements()) {
+ return null;
+ }
+ final String IMPLEMENTATION_NAME = HibernatePersistence.class.getName();
+ List<String> res = null;
+ while (xmls.hasMoreElements() && res == null) {
+ URL url = xmls.nextElement();
+ List<PersistenceMetadata> metadataFiles = null;
+ try {
+ metadataFiles = PersistenceXmlLoader.deploy(
+ url, CollectionHelper.EMPTY_MAP,
+ er,
+ PersistenceUnitTransactionType.RESOURCE_LOCAL);
+ } catch (Exception e1) {
+ //ignore
+ }
+ if (metadataFiles == null) {
+ continue;
+ }
+ boolean stopErrorFlag = false;
+ for (PersistenceMetadata metadata : metadataFiles) {
+ boolean tmp = metadata.getProvider() == null;
+ tmp = tmp || IMPLEMENTATION_NAME.equalsIgnoreCase(metadata.getProvider());
+ if (!tmp) {
+ continue;
+ }
+ //correct provider
+ //lazy compute the visitor if possible to avoid useless exceptions if an unexpected
state happens
+ JarVisitor visitor = null;
+ URL visitorJarURL = null;
+ if (metadata.getName() == null) {
+ visitor = getMainJarVisitor(url, metadata, CollectionHelper.EMPTY_MAP);
+ visitorJarURL = JarVisitorFactory.getJarURLFromURLEntry(url, "/" +
META_INF_PERS_XML); //$NON-NLS-1$
+ metadata.setName(visitor.getUnqualifiedJarName());
+ }
+ if (persistenceUnitName == null && xmls.hasMoreElements()) {
+ //throw new PersistenceException("No name provided and several persistence
units found");
+ stopErrorFlag = true;
+ break;
+ } else if (persistenceUnitName == null ||
metadata.getName().equals(persistenceUnitName)) {
+ if (visitor == null) {
+ visitor = getMainJarVisitor(url, metadata, CollectionHelper.EMPTY_MAP);
+ visitorJarURL = JarVisitorFactory.getJarURLFromURLEntry(url, "/" +
META_INF_PERS_XML); //$NON-NLS-1$
+ }
+ try {
+ addMetadataFromVisitor(visitor, visitorJarURL.getPath(), metadata);
+ /** /
+ JarVisitor.Filter[] otherXmlFilter = getFilters(metadata,
CollectionHelper.EMPTY_MAP, false);
+ for (String jarFile : metadata.getJarFiles()) {
+ // TODO: test this code
+ //vit//visitor = JarVisitor.getVisitor(jarFile, otherXmlFilter);
+ //vit//addMetadataFromVisitor(visitor, metadata);
+ }
+ /**/
+ } catch (IOException e) {
+ //ignore
+ }
+ res = new ArrayList<String>();
+ Iterator<NamedInputStream> it = metadata.getHbmfiles().iterator();
+ while (it.hasNext()) {
+ NamedInputStream nis = it.next();
+ res.add(nis.getName());
+ try {
+ nis.getStream().close();
+ } catch (IOException ioe) {
+ // TODO:
+ //HibernateConsolePlugin.getDefault().logErrorMessage("could not close
input stream for", ioe); //$NON-NLS-1$
+ }
+ }
+ break;
+ }
+ }
+ if (stopErrorFlag) {
+ break;
+ }
+ }
+ return res;
+ }
+
+ /**
+ * This function code based on code from Ejb3Configuration.
+ * @see JarVisitor Ejb3Configuration.getMainJarVisitor(URL url, PersistenceMetadata
metadata, Map integration)
+ *
+ * @param url
+ * @param metadata
+ * @param integration
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ private static JarVisitor getMainJarVisitor(URL url, PersistenceMetadata metadata, Map
integration) {
+ URL jarURL = JarVisitorFactory.getJarURLFromURLEntry(url, "/" +
META_INF_PERS_XML); //$NON-NLS-1$
+ Filter[] persistenceXmlFilter = getFilters(metadata, integration,
metadata.getExcludeUnlistedClasses());
+ JarVisitor visitor = JarVisitorFactory.getVisitor(jarURL, persistenceXmlFilter);
+ return visitor;
+ }
+
+ /**
+ * This function code based on code from Ejb3Configuration.
+ * @see JarVisitor Ejb3Configuration.addMetadataFromVisitor(JarVisitor visitor,
PersistenceMetadata metadata) throws IOException
+ *
+ * @param visitor
+ * @param metadata
+ * @throws IOException
+ */
+ @SuppressWarnings("unchecked")
+ private static void addMetadataFromVisitor(JarVisitor visitor, String addPath,
PersistenceMetadata metadata) throws IOException {
+ Set[] entries = visitor.getMatchingEntries();
+ Filter[] filters = visitor.getFilters();
+ int size = filters.length;
+ List<String> classes = metadata.getClasses();
+ List<String> packages = metadata.getPackages();
+ List<NamedInputStream> hbmFiles = metadata.getHbmfiles();
+ List<String> mappingFiles = metadata.getMappingFiles();
+ for (int index = 0; index < size; index++) {
+ for (Object o : entries[index]) {
+ Entry entry = (Entry) o;
+ if (filters[index] instanceof ClassFilter) {
+ classes.add(entry.getName());
+ } else if (filters[index] instanceof PackageFilter) {
+ packages.add(entry.getName());
+ } else if (filters[index] instanceof FileFilter) {
+ hbmFiles.add(new NamedInputStream(addPath + "/" + entry.getName(),
//$NON-NLS-1$
+ entry.getInputStream()));
+ if (mappingFiles != null) {
+ mappingFiles.remove(entry.getName());
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * This function code based on code from Ejb3Configuration.
+ * @see boolean[] Ejb3Configuration.getDetectedArtifacts(Properties properties, Map
overridenProperties, boolean excludeIfNotOverriden)
+ *
+ * @param properties
+ * @param overridenProperties
+ * @param excludeIfNotOverriden
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ private static boolean[] getDetectedArtifacts(Properties properties, Map
overridenProperties, boolean excludeIfNotOverriden) {
+ //result[0] - detect classes
+ //result[1] - detect hbm
+ boolean[] result = { false, false };
+ String detect = overridenProperties != null ?
+ (String) overridenProperties.get(HibernatePersistence.AUTODETECTION) : null;
+ detect = detect == null ?
+ properties.getProperty( HibernatePersistence.AUTODETECTION) : detect;
+ if (detect == null && excludeIfNotOverriden) {
+ //not overridden through HibernatePersistence.AUTODETECTION so we comply with the spec
excludeUnlistedClasses
+ return result;
+ }
+ else if (detect == null){
+ detect = "class,hbm"; //$NON-NLS-1$
+ }
+ StringTokenizer st = new StringTokenizer(detect, ", ", false); //$NON-NLS-1$
+ while (st.hasMoreElements()) {
+ String element = (String)st.nextElement();
+ if ("class".equalsIgnoreCase(element)) { //$NON-NLS-1$
+ result[0] = true;
+ }
+ if ("hbm".equalsIgnoreCase(element)) { //$NON-NLS-1$
+ result[1] = true;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * This function code based on code from Ejb3Configuration.
+ * @see JarVisitor.Filter[] Ejb3Configuration.getFilters(PersistenceMetadata metadata,
Map overridenProperties, boolean excludeIfNotOverriden)
+ *
+ * @param metadata
+ * @param overridenProperties
+ * @param excludeIfNotOverriden
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ private static Filter[] getFilters(PersistenceMetadata metadata, Map
overridenProperties, boolean excludeIfNotOverriden) {
+ Properties properties = metadata.getProps();
+ final List<String> mappingFiles = metadata.getMappingFiles();
+ boolean[] detectedArtifacts = getDetectedArtifacts(properties, overridenProperties,
excludeIfNotOverriden);
+ return getFilters(detectedArtifacts, true, mappingFiles);
+ }
+
+ private static Filter[] getFilters(final boolean[] detectedArtifacts, final boolean
searchORM, final List<String> mappingFiles) {
+ final int mappingFilesSize = mappingFiles != null ? mappingFiles.size() : 0;
+ int size = (detectedArtifacts[0] ? 2 : 0) + ((searchORM || detectedArtifacts[1] ||
mappingFilesSize > 0) ? 1 : 0);
+ Filter[] filters = new Filter[size];
+ if (detectedArtifacts[0]) {
+ filters[0] = new PackageFilter(false, null) {
+ public boolean accept(String javaElementName) {
+ return true;
+ }
+ };
+ filters[1] = new ClassFilter(
+ false, new Class[] {
+ Entity.class,
+ MappedSuperclass.class,
+ Embeddable.class}
+ ) {
+ public boolean accept(String javaElementName) {
+ return true;
+ }
+ };
+ }
+ if (detectedArtifacts[1] || searchORM || mappingFilesSize > 0) {
+ filters[size - 1] = new FileFilter(true) {
+ public boolean accept(String javaElementName) {
+ return (detectedArtifacts[1] &&
javaElementName.endsWith("hbm.xml")) //$NON-NLS-1$
+ || (searchORM && javaElementName.endsWith(META_INF_ORM_XML))
+ || (mappingFilesSize > 0 && mappingFiles.contains(javaElementName));
+ }
+ };
+ }
+ return filters;
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/ParserHelper.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/ParserHelper.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/ParserHelper.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,9 @@
+package org.hibernate.mediator.stubs.util;
+
+public class ParserHelper {
+ public static final String HQL_VARIABLE_PREFIX = ":"; //$NON-NLS-1$
+
+ public static final String HQL_SEPARATORS = "
\n\r\f\t,()=<>&|+-=/*'^![]#~\\"; //$NON-NLS-1$
+ //NOTICE: no " or . since they are part of (compound) identifiers
+ public static final String PATH_SEPARATORS = "."; //$NON-NLS-1$
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/ReflectHelper.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/ReflectHelper.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/ReflectHelper.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,29 @@
+package org.hibernate.mediator.stubs.util;
+
+//org.hibernate.util.ReflectHelper
+public final class ReflectHelper {
+
+ @SuppressWarnings("unchecked")
+ public static Class classForName(String name) throws ClassNotFoundException {
+ try {
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ if (contextClassLoader != null) {
+ return contextClassLoader.loadClass(name);
+ }
+ } catch (Throwable ignore) {
+ }
+ return Class.forName(name);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Class classForName(String name, Class caller) throws
ClassNotFoundException {
+ try {
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ if (contextClassLoader != null) {
+ return contextClassLoader.loadClass(name);
+ }
+ } catch (Throwable ignore) {
+ }
+ return Class.forName(name, true, caller.getClassLoader());
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/StringHelper.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/StringHelper.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/StringHelper.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,79 @@
+package org.hibernate.mediator.stubs.util;
+
+import java.util.ArrayList;
+
+import org.hibernate.util.ArrayHelper;
+
+// org.hibernate.util.StringHelper
+public final class StringHelper {
+ public static final String WHITESPACE = " \n\r\f\t"; //$NON-NLS-1$
+
+ public static boolean isNotEmpty(String string) {
+ return string != null && string.length() > 0;
+ }
+
+ public static boolean isEmpty(String string) {
+ return string == null || string.length() == 0;
+ }
+
+ public static String unqualify(String qualifiedName) {
+ int loc = qualifiedName.lastIndexOf("."); //$NON-NLS-1$
+ return (loc < 0) ? qualifiedName : qualifiedName.substring(loc + 1);
+ }
+
+ public static String qualifier(String qualifiedName) {
+ int loc = qualifiedName.lastIndexOf("."); //$NON-NLS-1$
+ return (loc < 0) ? "" : qualifiedName.substring(0, loc); //$NON-NLS-1$
+ }
+
+ public static String qualify(String prefix, String name) {
+ if (name == null || prefix == null) {
+ throw new NullPointerException();
+ }
+ return new StringBuffer(prefix.length() + name.length() +
1).append(prefix).append('.')
+ .append(name).toString();
+ }
+
+ public static String join(String seperator, String[] strings) {
+ int length = strings.length;
+ if (length == 0)
+ return ""; //$NON-NLS-1$
+ StringBuffer buf = new StringBuffer(length * strings[0].length()).append(strings[0]);
+ for (int i = 1; i < length; i++) {
+ buf.append(seperator).append(strings[i]);
+ }
+ return buf.toString();
+ }
+
+ public static int[] locateUnquoted(String string, char character) {
+ if ( '\'' == character ) {
+ throw new IllegalArgumentException( "Unquoted count of quotes is invalid" );
//$NON-NLS-1$
+ }
+ if (string == null) {
+ return new int[0];
+ }
+
+ ArrayList<Integer> locations = new ArrayList<Integer>( 20 );
+
+ // Impl note: takes advantage of the fact that an escpaed single quote
+ // embedded within a quote-block can really be handled as two seperate
+ // quote-blocks for the purposes of this method...
+ int stringLength = string.length();
+ boolean inQuote = false;
+ for ( int indx = 0; indx < stringLength; indx++ ) {
+ char c = string.charAt( indx );
+ if ( inQuote ) {
+ if ( '\'' == c ) {
+ inQuote = false;
+ }
+ }
+ else if ( '\'' == c ) {
+ inQuote = true;
+ }
+ else if ( c == character ) {
+ locations.add( new Integer( indx ) );
+ }
+ }
+ return ArrayHelper.toIntArray( locations );
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/XMLHelper.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/XMLHelper.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/util/XMLHelper.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,45 @@
+package org.hibernate.mediator.stubs.util;
+
+import java.util.List;
+
+import org.dom4j.io.SAXReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXParseException;
+
+@SuppressWarnings("unchecked")
+public class XMLHelper {
+
+ private static final Logger log = LoggerFactory.getLogger(XMLHelper.class);
+ private SAXReader saxReader;
+
+ public SAXReader createSAXReader(String file, List errorsList, EntityResolver
entityResolver) {
+ if (saxReader==null) saxReader = new SAXReader();
+ saxReader.setEntityResolver(entityResolver);
+ saxReader.setErrorHandler(new ErrorLogger(file, errorsList));
+ saxReader.setMergeAdjacentText(true);
+ saxReader.setValidation(true);
+ return saxReader;
+ }
+
+ public static class ErrorLogger implements ErrorHandler {
+ private String file;
+ private List errors;
+ ErrorLogger(String file, List errors) {
+ this.file=file;
+ this.errors = errors;
+ }
+ public void error(SAXParseException error) {
+ log.error( "Error parsing XML: " + file + '(' +
error.getLineNumber() + ") " + error.getMessage() ); //$NON-NLS-1$
//$NON-NLS-2$
+ errors.add(error);
+ }
+ public void fatalError(SAXParseException error) {
+ error(error);
+ }
+ public void warning(SAXParseException warn) {
+ log.warn( "Warning parsing XML: " + file + '(' +
warn.getLineNumber() + ") " + warn.getMessage() ); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/util/CollectionPropertySource.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/util/CollectionPropertySource.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/util/CollectionPropertySource.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.hibernate.mediator.util;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+
+public class CollectionPropertySource implements IPropertySource {
+
+ private Collection<?> collection;
+
+ IPropertyDescriptor[] descriptors = null;
+
+ Map<Object, Object> values = new WeakHashMap<Object, Object>();
+
+ public CollectionPropertySource(Collection<?> propertyValue) {
+ collection = propertyValue;
+ }
+
+ public Object getEditableValue() {
+ return null;
+ }
+
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ if (descriptors == null) {
+ PropertyDescriptor[] properties = new PropertyDescriptor[collection.size()];
+ for (int i = 0; i < properties.length; i++) {
+ properties[i] = new PropertyDescriptor(Integer.valueOf(i), "#" + i);
//$NON-NLS-1$
+ }
+ descriptors = properties;
+ }
+ return descriptors;
+ }
+
+ public Object getPropertyValue(Object id) {
+ Object value = values.get(id);
+ if (value == null) {
+ Integer i = (Integer) id;
+ Iterator<?> iterator = collection.iterator();
+ int base = 0;
+
+ while (iterator.hasNext()) {
+
+ value = iterator.next();
+
+ if (base == i.intValue()) {
+ values.put(id, value);
+ return value;
+ } else {
+ value = null;
+ }
+ base++;
+ }
+ }
+
+ return value;
+ }
+
+ public boolean isPropertySet(Object id) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void resetPropertyValue(Object id) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setPropertyValue(Object id, Object value) {
+
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/util/ELTransformer.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/util/ELTransformer.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/util/ELTransformer.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,28 @@
+package org.hibernate.mediator.util;
+
+public class ELTransformer {
+
+ /**
+ * transform any #{el expressions} into named parameters so HQL validation won't
fail on it.
+ *
+ * @param hql
+ * @return
+ */
+ static public String removeEL(String hql) {
+ int elStart = hql.indexOf("#{"); //$NON-NLS-1$
+ int next = hql.indexOf("}", elStart); //$NON-NLS-1$
+
+ while (elStart != -1 && next != -1) {
+ String result = hql.substring(0, elStart);
+ result += ":_" + hql.substring(elStart + 2,
next).replaceAll("[^\\p{javaJavaIdentifierStart}]", "_") +
"_"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ result += hql.substring(next + 1);
+
+ hql = result;
+
+ elStart = hql.indexOf("#{"); //$NON-NLS-1$
+ next = hql.indexOf("}", elStart); //$NON-NLS-1$
+ }
+
+ return hql;
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/util/Formatter.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/util/Formatter.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/util/Formatter.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,375 @@
+package org.hibernate.mediator.util;
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.hibernate.mediator.stubs.util.StringHelper;
+
+/**
+ * Old formatter from previous Hibernate versions which allowed a bit more control, i.e.
we want *less* spaces not more.
+ * In here to simplify migration from 3.2 to 3.3 where this class changed.
+ *
+ */
+@SuppressWarnings({ "unchecked", "nls" })
+public class Formatter {
+
+ private static final Set BEGIN_CLAUSES = new HashSet();
+ private static final Set END_CLAUSES = new HashSet();
+ private static final Set LOGICAL = new HashSet();
+ private static final Set QUANTIFIERS = new HashSet();
+ private static final Set DML = new HashSet();
+ private static final Set MISC = new HashSet();
+ static {
+
+ BEGIN_CLAUSES.add("left");
+ BEGIN_CLAUSES.add("right");
+ BEGIN_CLAUSES.add("inner");
+ BEGIN_CLAUSES.add("outer");
+ BEGIN_CLAUSES.add("group");
+ BEGIN_CLAUSES.add("order");
+
+ END_CLAUSES.add("where");
+ END_CLAUSES.add("set");
+ END_CLAUSES.add("having");
+ END_CLAUSES.add("join");
+ END_CLAUSES.add("from");
+ END_CLAUSES.add("by");
+ END_CLAUSES.add("join");
+ END_CLAUSES.add("into");
+ END_CLAUSES.add("union");
+
+ LOGICAL.add("and");
+ LOGICAL.add("or");
+ LOGICAL.add("when");
+ LOGICAL.add("else");
+ LOGICAL.add("end");
+
+ QUANTIFIERS.add("in");
+ QUANTIFIERS.add("all");
+ QUANTIFIERS.add("exists");
+ QUANTIFIERS.add("some");
+ QUANTIFIERS.add("any");
+
+ DML.add("insert");
+ DML.add("update");
+ DML.add("delete");
+
+ MISC.add("select");
+ MISC.add("on");
+ //MISC.add("values");
+
+ }
+
+ String indentString = " ";
+ String initial = "\n ";
+
+ boolean beginLine = true;
+ boolean afterBeginBeforeEnd = false;
+ boolean afterByOrSetOrFromOrSelect = false;
+ boolean afterValues = false;
+ boolean afterOn = false;
+ boolean afterBetween = false;
+ boolean afterInsert = false;
+ int inFunction = 0;
+ int parensSinceSelect = 0;
+ private LinkedList parenCounts = new LinkedList();
+ private LinkedList afterByOrFromOrSelects = new LinkedList();
+
+ int indent = 1;
+
+ StringBuffer result = new StringBuffer();
+ StringTokenizer tokens;
+ String lastToken;
+ String token;
+ String lcToken;
+
+ public Formatter(String sql) {
+ tokens = new StringTokenizer(
+ sql,
+ "()+*/-=<>'`\"[]," + StringHelper.WHITESPACE,
+ true
+ );
+ }
+
+ public Formatter setInitialString(String initial) {
+ this.initial = initial;
+ return this;
+ }
+
+ public Formatter setIndentString(String indent) {
+ this.indentString = indent;
+ return this;
+ }
+
+ public String format() {
+
+ result.append(initial);
+
+ while ( tokens.hasMoreTokens() ) {
+ token = tokens.nextToken();
+ lcToken = token.toLowerCase();
+
+ if ( "'".equals(token) ) {
+ String t;
+ do {
+ t = tokens.nextToken();
+ token += t;
+ }
+ while ( !"'".equals(t) && tokens.hasMoreTokens() ); // cannot
handle single quotes
+ }
+ else if ( "\"".equals(token) ) {
+ String t;
+ do {
+ t = tokens.nextToken();
+ token += t;
+ }
+ while ( !"\"".equals(t) );
+ }
+
+ if ( afterByOrSetOrFromOrSelect && ",".equals(token) ) {
+ commaAfterByOrFromOrSelect();
+ }
+ else if ( afterOn && ",".equals(token) ) {
+ commaAfterOn();
+ }
+
+ else if ( "(".equals(token) ) {
+ openParen();
+ }
+ else if ( ")".equals(token) ) {
+ closeParen();
+ }
+
+ else if ( BEGIN_CLAUSES.contains(lcToken) ) {
+ beginNewClause();
+ }
+
+ else if ( END_CLAUSES.contains(lcToken) ) {
+ endNewClause();
+ }
+
+ else if ( "select".equals(lcToken) ) {
+ select();
+ }
+
+ else if ( DML.contains(lcToken) ) {
+ updateOrInsertOrDelete();
+ }
+
+ else if ( "values".equals(lcToken) ) {
+ values();
+ }
+
+ else if ( "on".equals(lcToken) ) {
+ on();
+ }
+
+ else if ( afterBetween && lcToken.equals("and") ) {
+ misc();
+ afterBetween = false;
+ }
+
+ else if ( LOGICAL.contains(lcToken) ) {
+ logical();
+ }
+
+ else if ( isWhitespace(token) ) {
+ white();
+ }
+
+ else {
+ misc();
+ }
+
+ if ( !isWhitespace( token ) ) lastToken = lcToken;
+
+ }
+ return result.toString();
+ }
+
+ private void commaAfterOn() {
+ out();
+ indent--;
+ newline();
+ afterOn = false;
+ afterByOrSetOrFromOrSelect = true;
+ }
+
+ private void commaAfterByOrFromOrSelect() {
+ out();
+ newline();
+ }
+
+ private void logical() {
+ if ( "end".equals(lcToken) ) indent--;
+ newline();
+ out();
+ beginLine = false;
+ }
+
+ private void on() {
+ indent++;
+ afterOn = true;
+ newline();
+ out();
+ beginLine = false;
+ }
+
+ private void misc() {
+ out();
+ if ( "between".equals(lcToken) ) {
+ afterBetween = true;
+ }
+ if (afterInsert) {
+ newline();
+ afterInsert = false;
+ }
+ else {
+ beginLine = false;
+ if ( "case".equals(lcToken) ) {
+ indent++;
+ }
+ }
+ }
+
+ private void white() {
+ if ( !beginLine ) {
+ result.append(" ");
+ }
+ }
+
+ private void updateOrInsertOrDelete() {
+ out();
+ indent++;
+ beginLine = false;
+ if ( "update".equals(lcToken) ) newline();
+ if ( "insert".equals(lcToken) ) afterInsert = true;
+ }
+
+ private void select() {
+ out();
+ indent++;
+ newline();
+ parenCounts.addLast( new Integer(parensSinceSelect) );
+ afterByOrFromOrSelects.addLast( new Boolean(afterByOrSetOrFromOrSelect) );
+ parensSinceSelect = 0;
+ afterByOrSetOrFromOrSelect = true;
+ }
+
+ private void out() {
+ result.append(token);
+ }
+
+ private void endNewClause() {
+ if (!afterBeginBeforeEnd) {
+ indent--;
+ if (afterOn) {
+ indent--;
+ afterOn=false;
+ }
+ newline();
+ }
+ out();
+ if ( !"union".equals(lcToken) ) indent++;
+ newline();
+ afterBeginBeforeEnd = false;
+ afterByOrSetOrFromOrSelect = "by".equals(lcToken)
+ || "set".equals(lcToken)
+ || "from".equals(lcToken);
+ }
+
+ private void beginNewClause() {
+ if (!afterBeginBeforeEnd) {
+ if (afterOn) {
+ indent--;
+ afterOn=false;
+ }
+ indent--;
+ newline();
+ }
+ out();
+ beginLine = false;
+ afterBeginBeforeEnd = true;
+ }
+
+ private void values() {
+ indent--;
+ newline();
+ out();
+ indent++;
+ newline();
+ afterValues = true;
+ }
+
+ private void closeParen() {
+ parensSinceSelect--;
+ if (parensSinceSelect<0) {
+ indent--;
+ parensSinceSelect = ( (Integer) parenCounts.removeLast() ).intValue();
+ afterByOrSetOrFromOrSelect = ( (Boolean) afterByOrFromOrSelects.removeLast()
).booleanValue();
+ }
+ if ( inFunction>0 ) {
+ inFunction--;
+ out();
+ }
+ else {
+ if (!afterByOrSetOrFromOrSelect) {
+ indent--;
+ newline();
+ }
+ out();
+ }
+ beginLine = false;
+ }
+
+ private void openParen() {
+ if ( isFunctionName( lastToken ) || inFunction>0 ) {
+ inFunction++;
+ }
+ beginLine = false;
+ if ( inFunction>0 ) {
+ out();
+ }
+ else {
+ out();
+ if (!afterByOrSetOrFromOrSelect) {
+ indent++;
+ newline();
+ beginLine = true;
+ }
+ }
+ parensSinceSelect++;
+ }
+
+ private static boolean isFunctionName(String tok) {
+ final char begin = tok.charAt(0);
+ final boolean isIdentifier = Character.isJavaIdentifierStart( begin ) ||
'"'==begin;
+ return isIdentifier &&
+ !LOGICAL.contains(tok) &&
+ !END_CLAUSES.contains(tok) &&
+ !QUANTIFIERS.contains(tok) &&
+ !DML.contains(tok) &&
+ !MISC.contains(tok);
+ }
+
+ private static boolean isWhitespace(String token) {
+ return StringHelper.WHITESPACE.indexOf(token)>=0;
+ }
+
+ private void newline() {
+ result.append("\n");
+ for ( int i=0; i<indent; i++ ) {
+ result.append(indentString);
+ }
+ beginLine = true;
+ }
+
+ public static void main(String[] args) {
+ if ( args.length>0 ) System.out.println(
+ new Formatter( StringHelper.join(" ", args) ).format()
+ );
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/util/QLFormatHelper.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/util/QLFormatHelper.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/util/QLFormatHelper.java 2010-03-29
15:58:02 UTC (rev 21117)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.hibernate.mediator.util;
+
+public class QLFormatHelper {
+
+ static public String formatForScreen(String query) {
+ return new Formatter(query).setInitialString("").setIndentString("
").format(); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+}