Author: max.andersen(a)jboss.com
Date: 2010-02-09 17:44:05 -0500 (Tue, 09 Feb 2010)
New Revision: 20207
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/Formatter.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/cglib-2.2.jar
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/commons-collections-3.1.jar
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/hibernate-jmx.jar
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/slf4j-api-1.5.8.jar
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/slf4j-log4j12-1.5.8.jar
Removed:
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/cglib-2.1.3.jar
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/commons-collections-2.1.1.jar
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/OpenMappingUtilsEjb3.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/QLFormatHelper.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/.classpath
trunk/hibernatetools/plugins/org.hibernate.eclipse/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.hibernate.eclipse/build.properties
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/annotations/ejb3-persistence.jar
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/annotations/hibernate-commons-annotations.jar
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/asm.jar
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/javassist.jar
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/jboss-cache.jar
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/jta.jar
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/FakeTransactionManagerLookup.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/.classpath
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/lib/ejb3-persistence.jar
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/lib/hibernate3.jar
Log:
JBIDE-5706 Moved to hibernate 3.3.2 to pick up many bugfixes in annotation and
entitymanager code.
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/.classpath
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/.classpath 2010-02-09 21:07:14 UTC
(rev 20206)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/.classpath 2010-02-09 22:44:05 UTC
(rev 20207)
@@ -5,12 +5,8 @@
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib"
path="lib/hibernate/asm.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/hibernate/asm-attrs.jar"/>
- <classpathentry exported="true" kind="lib"
path="lib/hibernate/commons-collections-2.1.1.jar"/>
- <classpathentry exported="true" kind="lib"
path="lib/hibernate/commons-logging-1.0.4.jar"/>
- <classpathentry exported="true" kind="lib"
path="lib/hibernate/concurrent-1.3.2.jar"/>
- <classpathentry exported="true" kind="lib"
path="lib/hibernate/connector.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/hibernate/dom4j-1.6.1.jar"/>
- <classpathentry exported="true" kind="lib"
path="lib/hibernate/hibernate3.jar" sourcepath="/hibernate-3.2"/>
+ <classpathentry exported="true" kind="lib"
path="lib/hibernate/hibernate3.jar"
sourcepath="C:/Temp/_hibernate/hibernate-core-3.3.2.GA-sources.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/hibernate/jboss-cache.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/hibernate/jboss-common.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/hibernate/jboss-jmx.jar"/>
@@ -21,21 +17,28 @@
<classpathentry exported="true" kind="lib"
path="lib/hibernate/oscache-2.1.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/hibernate/proxool-0.8.3.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/hibernate/swarmcache-1.0rc2.jar"/>
- <classpathentry exported="true" kind="lib"
path="lib/tools/hibernate-tools.jar"
sourcepath="/hibernateext.tools"/>
- <classpathentry exported="true" kind="lib"
path="lib/tools/freemarker.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/bsh-core-2.0b4.jar"/>
- <classpathentry exported="true" kind="lib"
path="lib/annotations/ejb3-persistence.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/annotations/hibernate-annotations.jar"/>
- <classpathentry exported="true" kind="lib"
path="lib/hibernate/cglib-2.1.3.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/hibernate/jgroups-2.2.8.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/hibernate/antlr-2.7.6.jar"/>
- <classpathentry exported="true" kind="lib"
path="lib/tools/jtidy-r8-20060801.jar"/>
- <classpathentry exported="true" kind="lib"
path="lib/annotations/hibernate-entitymanager.jar"
sourcepath="/hibernateext.entitymanager"/>
+ <classpathentry exported="true" kind="lib"
path="lib/annotations/hibernate-entitymanager.jar"
sourcepath="C:/Temp/_hibernate/hibernate-entitymanager-3.4.0.GA-sources.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/hibernate/javassist.jar"/>
- <classpathentry exported="true" kind="lib"
path="lib/hibernate/ehcache-1.2.3.jar"/>
- <classpathentry exported="true" kind="lib"
path="lib/hibernate/c3p0-0.9.1.jar"/>
- <classpathentry exported="true" kind="lib"
path="lib/annotations/hibernate-commons-annotations.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/annotations/hibernate-validator.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/hibernate/log4j-1.2.15.jar"/>
+ <classpathentry exported="true" kind="lib"
path="lib/hibernate/hibernate-jmx.jar"/>
+ <classpathentry exported="true" kind="lib"
path="lib/hibernate/commons-collections-3.1.jar"/>
+ <classpathentry exported="true" 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"/>
+ <classpathentry exported="true" kind="lib"
path="lib/annotations/hibernate-commons-annotations.jar"/>
+ <classpathentry exported="true" kind="lib"
path="lib/annotations/ejb3-persistence.jar"/>
+ <classpathentry exported="true" 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 exported="true" kind="lib"
path="lib/hibernate/concurrent-1.3.2.jar"/>
+ <classpathentry exported="true" kind="lib"
path="lib/hibernate/connector.jar"/>
+ <classpathentry exported="true" kind="lib"
path="lib/hibernate/ehcache-1.2.3.jar"/>
+ <classpathentry exported="true" kind="lib"
path="lib/hibernate/slf4j-log4j12-1.5.8.jar"/>
+ <classpathentry exported="true" kind="lib"
path="lib/tools/freemarker.jar"/>
+ <classpathentry exported="true" kind="lib"
path="lib/tools/hibernate-tools.jar"/>
+ <classpathentry exported="true" kind="lib"
path="lib/tools/jtidy-r8-20060801.jar"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/META-INF/MANIFEST.MF
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/META-INF/MANIFEST.MF 2010-02-09
21:07:14 UTC (rev 20206)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/META-INF/MANIFEST.MF 2010-02-09
22:44:05 UTC (rev 20207)
@@ -40,7 +40,12 @@
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/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-Activator: org.hibernate.eclipse.HibernatePlugin
Bundle-Vendor: %Bundle-Vendor.0
Bundle-Localization: plugin
@@ -144,7 +149,9 @@
hbm,
javassist,
javassist.bytecode,
+ javassist.bytecode.analysis,
javassist.bytecode.annotation,
+ javassist.bytecode.stackmap,
javassist.compiler,
javassist.compiler.ast,
javassist.convert,
@@ -183,7 +190,6 @@
net.sf.cglib.proxy,
net.sf.cglib.reflect,
net.sf.cglib.transform,
- net.sf.cglib.transform.hook,
net.sf.cglib.transform.impl,
net.sf.cglib.util,
net.sf.ehcache,
@@ -201,8 +207,17 @@
net.sf.ehcache.util,
net.sf.swarmcache,
org.apache.commons.collections,
+ org.apache.commons.collections.bag,
+ org.apache.commons.collections.bidimap,
+ org.apache.commons.collections.buffer,
+ org.apache.commons.collections.collection,
org.apache.commons.collections.comparators,
+ org.apache.commons.collections.functors,
org.apache.commons.collections.iterators,
+ org.apache.commons.collections.keyvalue,
+ org.apache.commons.collections.list,
+ org.apache.commons.collections.map,
+ org.apache.commons.collections.set,
org.apache.commons.logging,
org.apache.commons.logging.impl,
org.apache.log4j,
@@ -251,16 +266,21 @@
org.hibernate.annotations.common.reflection.java.generics,
org.hibernate.annotations.common.util,
org.hibernate.bytecode,
+ org.hibernate.bytecode.buildtime,
org.hibernate.bytecode.cglib,
org.hibernate.bytecode.javassist,
org.hibernate.bytecode.util,
org.hibernate.cache,
+ org.hibernate.cache.access,
org.hibernate.cache.entry,
+ org.hibernate.cache.impl,
+ org.hibernate.cache.impl.bridge,
org.hibernate.cfg,
org.hibernate.cfg.annotations,
org.hibernate.cfg.annotations.reflection,
org.hibernate.cfg.reveng,
org.hibernate.cfg.reveng.dialect,
+ org.hibernate.cfg.search,
org.hibernate.classic,
org.hibernate.collection,
org.hibernate.connection,
@@ -273,7 +293,9 @@
org.hibernate.dialect,
org.hibernate.dialect.function,
org.hibernate.dialect.lock,
+ org.hibernate.dialect.resolver,
org.hibernate.eclipse,
+ org.hibernate.eclipse.launch,
org.hibernate.eclipse.logging,
org.hibernate.eclipse.logging.xpl,
org.hibernate.ejb,
@@ -306,6 +328,7 @@
org.hibernate.intercept.cglib,
org.hibernate.intercept.javassist,
org.hibernate.jdbc,
+ org.hibernate.jdbc.util,
org.hibernate.jmx,
org.hibernate.loader,
org.hibernate.loader.collection,
@@ -362,14 +385,20 @@
org.jboss,
org.jboss.cache,
org.jboss.cache.aop,
+ org.jboss.cache.aop.annotation,
org.jboss.cache.aop.collection,
+ org.jboss.cache.aop.eviction,
+ org.jboss.cache.aop.interceptors,
+ org.jboss.cache.aop.references,
org.jboss.cache.aop.util,
+ org.jboss.cache.buddyreplication,
org.jboss.cache.config,
org.jboss.cache.eviction,
org.jboss.cache.factories,
org.jboss.cache.interceptors,
org.jboss.cache.loader,
org.jboss.cache.loader.bdbje,
+ org.jboss.cache.loader.jdbm,
org.jboss.cache.loader.rmi,
org.jboss.cache.loader.tcp,
org.jboss.cache.lock,
@@ -478,6 +507,10 @@
org.logicalcobwebs.proxool.util,
org.objectweb.asm,
org.objectweb.asm.attrs,
+ org.slf4j,
+ org.slf4j.helpers,
+ org.slf4j.impl,
+ org.slf4j.spi,
org.w3c.tidy,
org.w3c.tidy.ant,
pojo
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/build.properties
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/build.properties 2010-02-09
21:07:14 UTC (rev 20206)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/build.properties 2010-02-09
22:44:05 UTC (rev 20207)
@@ -12,14 +12,17 @@
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/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
+ 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.eclipse.jar
source.org.hibernate.eclipse.jar = src/
output.org.hibernate.eclipse.jar = bin/
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/annotations/ejb3-persistence.jar
===================================================================
(Binary files differ)
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/annotations/hibernate-commons-annotations.jar
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/asm.jar
===================================================================
(Binary files differ)
Deleted: trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/cglib-2.1.3.jar
===================================================================
(Binary files differ)
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/cglib-2.2.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/cglib-2.2.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted:
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/commons-collections-2.1.1.jar
===================================================================
(Binary files differ)
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/commons-collections-3.1.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/commons-collections-3.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/hibernate-jmx.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/hibernate-jmx.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/javassist.jar
===================================================================
(Binary files differ)
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/jboss-cache.jar
===================================================================
(Binary files differ)
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/jta.jar
===================================================================
(Binary files differ)
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/slf4j-api-1.5.8.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/slf4j-api-1.5.8.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/slf4j-log4j12-1.5.8.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/hibernatetools/plugins/org.hibernate.eclipse/lib/hibernate/slf4j-log4j12-1.5.8.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2010-02-09
21:07:14 UTC (rev 20206)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java 2010-02-09
22:44:05 UTC (rev 20207)
@@ -34,7 +34,6 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.sql.Connection;
-import java.sql.DatabaseMetaData;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;
@@ -66,7 +65,7 @@
import org.hibernate.console.preferences.ConsoleConfigurationPreferences;
import
org.hibernate.console.preferences.ConsoleConfigurationPreferences.ConfigurationMode;
import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.DialectFactory;
+import org.hibernate.dialect.resolver.DialectFactory;
import org.hibernate.util.ConfigHelper;
import org.hibernate.util.ReflectHelper;
import org.hibernate.util.StringHelper;
@@ -373,11 +372,8 @@
Connection connection = null;
try {
connection = DriverManager.getConnection(url, user, pass);
- DatabaseMetaData meta = connection.getMetaData();
- String databaseName = meta.getDatabaseProductName();
- int databaseMajorVersion = meta.getDatabaseMajorVersion();
//SQL Dialect:
- Dialect dialect = DialectFactory.buildDialect( localCfg.getProperties(),
databaseName, databaseMajorVersion );
+ Dialect dialect = DialectFactory.buildDialect( localCfg.getProperties(),
connection );
localCfg.setProperty(Environment.DIALECT, dialect.toString());
} catch (SQLException e) {
//can't determine dialect
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/FakeTransactionManagerLookup.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/FakeTransactionManagerLookup.java 2010-02-09
21:07:14 UTC (rev 20206)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/FakeTransactionManagerLookup.java 2010-02-09
22:44:05 UTC (rev 20207)
@@ -37,6 +37,10 @@
return null; //throw new UnsupportedOperationException();
}
+ public Object getTransactionIdentifier(Transaction transaction) {
+ return transaction;
+ }
+
}
class FakeTransactionManager implements TransactionManager {
Added:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/Formatter.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/Formatter.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/Formatter.java 2010-02-09
22:44:05 UTC (rev 20207)
@@ -0,0 +1,375 @@
+package org.hibernate.eclipse.console.utils;
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.hibernate.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()
+ );
+ }
+
+}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/OpenMappingUtilsEjb3.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/OpenMappingUtilsEjb3.java 2010-02-09
21:07:14 UTC (rev 20206)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/OpenMappingUtilsEjb3.java 2010-02-09
22:44:05 UTC (rev 20207)
@@ -20,8 +20,14 @@
import org.hibernate.eclipse.console.HibernateConsolePlugin;
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.util.CollectionHelper;
@@ -88,18 +94,17 @@
URL visitorJarURL = null;
if (metadata.getName() == null) {
visitor = getMainJarVisitor(url, metadata, CollectionHelper.EMPTY_MAP);
- visitorJarURL = JarVisitor.getJarURLFromURLEntry(url, "/" +
META_INF_PERS_XML); //$NON-NLS-1$
+ 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" );
+ //throw new PersistenceException("No name provided and several persistence
units found");
stopErrorFlag = true;
break;
- }
- else if (persistenceUnitName == null ||
metadata.getName().equals(persistenceUnitName)) {
+ } else if (persistenceUnitName == null ||
metadata.getName().equals(persistenceUnitName)) {
if (visitor == null) {
visitor = getMainJarVisitor(url, metadata, CollectionHelper.EMPTY_MAP);
- visitorJarURL = JarVisitor.getJarURLFromURLEntry(url, "/" +
META_INF_PERS_XML); //$NON-NLS-1$
+ visitorJarURL = JarVisitorFactory.getJarURLFromURLEntry(url, "/" +
META_INF_PERS_XML); //$NON-NLS-1$
}
try {
addMetadataFromVisitor(visitor, visitorJarURL.getPath(), metadata);
@@ -145,10 +150,11 @@
* @param integration
* @return
*/
- public static JarVisitor getMainJarVisitor(URL url, PersistenceMetadata metadata, Map
integration) {
- URL jarURL = JarVisitor.getJarURLFromURLEntry(url, "/" + META_INF_PERS_XML);
//$NON-NLS-1$
- JarVisitor.Filter[] persistenceXmlFilter = getFilters(metadata, integration,
metadata.getExcludeUnlistedClasses());
- JarVisitor visitor = JarVisitor.getVisitor(jarURL, persistenceXmlFilter);
+ @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;
}
@@ -160,28 +166,28 @@
* @param metadata
* @throws IOException
*/
- public static void addMetadataFromVisitor(JarVisitor visitor, String addPath,
PersistenceMetadata metadata) throws IOException {
+ @SuppressWarnings("unchecked")
+ private static void addMetadataFromVisitor(JarVisitor visitor, String addPath,
PersistenceMetadata metadata) throws IOException {
Set[] entries = visitor.getMatchingEntries();
- JarVisitor.Filter[] filters = visitor.getFilters();
+ 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++) {
- Iterator homogeneousEntry = entries[index].iterator();
- while (homogeneousEntry.hasNext()) {
- JarVisitor.Entry entry = (JarVisitor.Entry) homogeneousEntry.next();
- if (filters[index] instanceof JarVisitor.ClassFilter) {
- //TODO only add entry if there is annotations (Javassist)
+ for (Object o : entries[index]) {
+ Entry entry = (Entry) o;
+ if (filters[index] instanceof ClassFilter) {
classes.add(entry.getName());
- }
- else if (filters[index] instanceof JarVisitor.PackageFilter) {
+ } else if (filters[index] instanceof PackageFilter) {
packages.add(entry.getName());
- }
- else if (filters[index] instanceof JarVisitor.FileFilter) {
- hbmFiles.add(new NamedInputStream(addPath + "/" + entry.getName(),
//$NON-NLS-1$
+ } else if (filters[index] instanceof FileFilter) {
+ hbmFiles.add(new NamedInputStream(addPath + "/" + entry.getName(),
//$NON-NLS-1$
entry.getInputStream()));
- metadata.getMappingFiles().remove(entry.getName());
+ if (mappingFiles != null) {
+ mappingFiles.remove(entry.getName());
+ }
}
}
}
@@ -196,7 +202,8 @@
* @param excludeIfNotOverriden
* @return
*/
- public static boolean[] getDetectedArtifacts(Properties properties, Map
overridenProperties, boolean excludeIfNotOverriden) {
+ @SuppressWarnings("unchecked")
+ private static boolean[] getDetectedArtifacts(Properties properties, Map
overridenProperties, boolean excludeIfNotOverriden) {
//result[0] - detect classes
//result[1] - detect hbm
boolean[] result = { false, false };
@@ -205,7 +212,7 @@
detect = detect == null ?
properties.getProperty( HibernatePersistence.AUTODETECTION) : detect;
if (detect == null && excludeIfNotOverriden) {
- //not overriden through HibernatePersistence.AUTODETECTION so we comply with the spec
excludeUnlistedClasses
+ //not overridden through HibernatePersistence.AUTODETECTION so we comply with the spec
excludeUnlistedClasses
return result;
}
else if (detect == null){
@@ -233,21 +240,26 @@
* @param excludeIfNotOverriden
* @return
*/
- public static JarVisitor.Filter[] getFilters(PersistenceMetadata metadata, Map
overridenProperties, boolean excludeIfNotOverriden) {
+ @SuppressWarnings("unchecked")
+ private static Filter[] getFilters(PersistenceMetadata metadata, Map
overridenProperties, boolean excludeIfNotOverriden) {
Properties properties = metadata.getProps();
final List<String> mappingFiles = metadata.getMappingFiles();
- boolean[] result = getDetectedArtifacts(properties, overridenProperties,
excludeIfNotOverriden);
+ boolean[] detectedArtifacts = getDetectedArtifacts(properties, overridenProperties,
excludeIfNotOverriden);
+ return getFilters(detectedArtifacts, true, mappingFiles);
+ }
- int size = ( result[0] ? 2 : 0 ) + 1; //class involves classes and packages, xml files
are always involved because of orm.xml
- JarVisitor.Filter[] filters = new JarVisitor.Filter[size];
- if (result[0]) {
- filters[0] = new JarVisitor.PackageFilter(false, null) {
+ 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 JarVisitor.ClassFilter(
- false, new Class[]{
+ filters[1] = new ClassFilter(
+ false, new Class[] {
Entity.class,
MappedSuperclass.class,
Embeddable.class}
@@ -257,23 +269,15 @@
}
};
}
- if (result[1]) {
- filters[size - 1] = new JarVisitor.FileFilter(true) {
+ if (detectedArtifacts[1] || searchORM || mappingFilesSize > 0) {
+ filters[size - 1] = new FileFilter(true) {
public boolean accept(String javaElementName) {
- return javaElementName.endsWith("hbm.xml") //$NON-NLS-1$
- || javaElementName.endsWith(META_INF_ORM_XML)
- || mappingFiles.contains(javaElementName);
+ return (detectedArtifacts[1] &&
javaElementName.endsWith("hbm.xml")) //$NON-NLS-1$
+ || (searchORM && javaElementName.endsWith(META_INF_ORM_XML))
+ || (mappingFilesSize > 0 && mappingFiles.contains(javaElementName));
}
};
}
- else {
- filters[size - 1] = new JarVisitor.FileFilter(true) {
- public boolean accept(String javaElementName) {
- return javaElementName.endsWith(META_INF_ORM_XML)
- || mappingFiles.contains(javaElementName);
- }
- };
- }
return filters;
}
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/QLFormatHelper.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/QLFormatHelper.java 2010-02-09
21:07:14 UTC (rev 20206)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/utils/QLFormatHelper.java 2010-02-09
22:44:05 UTC (rev 20207)
@@ -21,8 +21,6 @@
*/
package org.hibernate.eclipse.console.utils;
-import org.hibernate.pretty.Formatter;
-
public class QLFormatHelper {
static public String formatForScreen(String query) {
Modified: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/.classpath
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/.classpath 2010-02-09
21:07:14 UTC (rev 20206)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/.classpath 2010-02-09
22:44:05 UTC (rev 20207)
@@ -1,7 +1,7 @@
<?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 exported="true" kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry exported="true" kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib"
path="lib/hibernate-tools-tests.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/hsqldb.jar"/>
@@ -17,5 +17,6 @@
<classpathentry exported="true" kind="lib"
path="lib/jmock-2.5.1/jmock-legacy-2.5.1.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/jmock-2.5.1/jmock-script-2.5.1.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/jmock-2.5.1/objenesis-1.0.jar"/>
+ <classpathentry kind="lib"
path="C:/Bin/mysql-connector-java-5.0.7/mysql-connector-java-5.0.7-bin.jar"
sourcepath="C:/Bin/mysql-connector-java-5.0.7/src"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/lib/ejb3-persistence.jar
===================================================================
(Binary files differ)
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/project/lib/hibernate3.jar
===================================================================
(Binary files differ)