Author: vyemialyanchyk
Date: 2010-04-08 14:12:18 -0400 (Thu, 08 Apr 2010)
New Revision: 21360
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/CriteriaStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HQLQueryPlanStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateProxyHelperStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/QueryStub.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/QueryTranslatorStub.java
Modified:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/.classpath
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/base/HObject.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/ConfigurationStubFactory.java
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SessionFactoryStub.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/TypeStubFactory.java
branches/hibernatetools-multiversion/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/hbmexporter/HbmExporterTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-6070 - create/invoke by string name - for all
classes 2
Modified:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/.classpath
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/.classpath 2010-04-08
17:37:44 UTC (rev 21359)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/.classpath 2010-04-08
18:12:18 UTC (rev 21360)
@@ -39,6 +39,6 @@
<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="lib" path="lib/bsh-core-2.0b4.jar"
sourcepath="D:/Temp/_hibernate/bsh/src/BeanShell/src/bsh.zip"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/base/HObject.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/base/HObject.java 2010-04-08
17:37:44 UTC (rev 21359)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/base/HObject.java 2010-04-08
18:12:18 UTC (rev 21360)
@@ -179,6 +179,10 @@
public static Object newInstance(final String cn, Object param0, Object param1, Object
param2) {
return newInstance(cn, new HObject[] { ho(param0), ho(param1), ho(param2) });
}
+
+ public static Object newInstance(final String cn, Object param0, Object param1, Object
param2, Object param3) {
+ return newInstance(cn, new HObject[] { ho(param0), ho(param1), ho(param2), ho(param3)
});
+ }
protected static HObject ho(Object obj) {
if (obj instanceof HObject) {
Modified:
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 2010-04-08
17:37:44 UTC (rev 21359)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ClassMetadataStub.java 2010-04-08
18:12:18 UTC (rev 21360)
@@ -1,5 +1,7 @@
package org.hibernate.mediator.stubs;
+import java.io.Serializable;
+
import org.hibernate.mediator.base.HObject;
public class ClassMetadataStub extends HObject {
@@ -42,4 +44,12 @@
return (Class<?>)invoke(mn(), pojo);
}
+ public boolean hasIdentifierProperty() {
+ return (Boolean)invoke(mn());
+ }
+
+ public Serializable getIdentifier(Object entity, EntityModeStub pojo) {
+ return (Serializable)invoke(mn(), entity, pojo);
+ }
+
}
Modified:
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 2010-04-08
17:37:44 UTC (rev 21359)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/ConfigurationStubFactory.java 2010-04-08
18:12:18 UTC (rev 21360)
@@ -37,9 +37,6 @@
private ConsoleConfigurationPreferences prefs = null;
public ConfigurationStubFactory(ConsoleConfigurationPreferences prefs) {
- if (prefs == null) {
- throw new HibernateConsoleRuntimeException(Messages.Stub_create_null_stub_prohibit);
- }
this.prefs = prefs;
}
@@ -52,7 +49,7 @@
}
public ConfigurationStub createConfiguration(ConfigurationStub localCfg, boolean
includeMappings) {
- Properties properties = prefs.getProperties();
+ Properties properties = prefs != null ? prefs.getProperties() : null;
if (properties != null) {
// to fix: JBIDE-5839 - setup this property: false is default value
// to make hibernate tools diff hibernate versions compatible
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/CriteriaStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/CriteriaStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/CriteriaStub.java 2010-04-08
18:12:18 UTC (rev 21360)
@@ -0,0 +1,22 @@
+package org.hibernate.mediator.stubs;
+
+import java.util.List;
+
+import org.hibernate.mediator.base.HObject;
+
+public class CriteriaStub extends HObject {
+ public static final String CL = "org.hibernate.Criteria"; //$NON-NLS-1$
+
+ protected CriteriaStub(Object criteria) {
+ super(criteria, CL);
+ }
+
+ public void setMaxResults(int intValue) {
+ invoke(mn(), intValue);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<Object> list() {
+ return (List<Object>)invoke(mn());
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HQLQueryPlanStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HQLQueryPlanStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HQLQueryPlanStub.java 2010-04-08
18:12:18 UTC (rev 21360)
@@ -0,0 +1,27 @@
+package org.hibernate.mediator.stubs;
+
+import java.util.Map;
+
+import org.hibernate.mediator.base.HObject;
+
+public class HQLQueryPlanStub extends HObject {
+ public static final String CL = "org.hibernate.engine.query.HQLQueryPlan";
//$NON-NLS-1$
+
+ protected HQLQueryPlanStub(Object hqlQueryPlan) {
+ super(hqlQueryPlan, CL);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static HQLQueryPlanStub newInstance(String hql, boolean shallow, Map
enabledFilters, SessionFactoryStub factory) {
+ return new HQLQueryPlanStub(HObject.newInstance(CL, hql, shallow, enabledFilters,
factory));
+ }
+
+ public QueryTranslatorStub[] getTranslators() {
+ Object[] queryTranslators = (Object[])invoke(mn());
+ QueryTranslatorStub[] res = new QueryTranslatorStub[queryTranslators.length];
+ for (int i = 0; i < queryTranslators.length; i++) {
+ res[i] = new QueryTranslatorStub(queryTranslators[i]);
+ }
+ return res;
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateProxyHelperStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateProxyHelperStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/HibernateProxyHelperStub.java 2010-04-08
18:12:18 UTC (rev 21360)
@@ -0,0 +1,11 @@
+package org.hibernate.mediator.stubs;
+
+import org.hibernate.mediator.base.HObject;
+
+public class HibernateProxyHelperStub {
+ public static final String CL = "org.hibernate.proxy.HibernateProxyHelper";
//$NON-NLS-1$
+
+ public static Class<?> getClassWithoutInitializingProxy(Object object) {
+ return (Class<?>)HObject.invokeStaticMethod(CL,
"getClassWithoutInitializingProxy"); //$NON-NLS-1$
+ }
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/QueryStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/QueryStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/QueryStub.java 2010-04-08
18:12:18 UTC (rev 21360)
@@ -0,0 +1,44 @@
+package org.hibernate.mediator.stubs;
+
+import java.util.List;
+
+import org.hibernate.mediator.base.HObject;
+
+public class QueryStub extends HObject {
+ public static final String CL = "org.hibernate.Query"; //$NON-NLS-1$
+
+ protected QueryStub(Object query) {
+ super(query, CL);
+ }
+
+ public String[] getReturnAliases() {
+ return (String[])invoke(mn());
+ }
+
+ public TypeStub[] getReturnTypes() {
+ Object[] returnTypes = (Object[])invoke(mn());
+ TypeStub[] res = new TypeStub[returnTypes.length];
+ for (int i = 0; i < returnTypes.length; i++) {
+ res[i] = TypeStubFactory.createTypeStub(returnTypes[i]);
+ }
+ return null;
+ }
+
+ public void setMaxResults(int intValue) {
+ invoke(mn(), intValue);
+ }
+
+ public void setParameter(int position, Object val, TypeStub type) {
+ invoke(mn(), position, val, type);
+ }
+
+ public void setParameter(String name, Object val, TypeStub type) {
+ invoke(mn(), name, val, type);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<Object> list() {
+ return (List<Object>)invoke(mn());
+ }
+
+}
Added:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/QueryTranslatorStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/QueryTranslatorStub.java
(rev 0)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/QueryTranslatorStub.java 2010-04-08
18:12:18 UTC (rev 21360)
@@ -0,0 +1,37 @@
+package org.hibernate.mediator.stubs;
+
+import java.util.List;
+import java.util.Set;
+
+import org.hibernate.mediator.base.HObject;
+
+public class QueryTranslatorStub extends HObject {
+ public static final String CL = "org.hibernate.hql.QueryTranslator";
//$NON-NLS-1$
+
+ protected QueryTranslatorStub(Object queryTranslator) {
+ super(queryTranslator, CL);
+ }
+
+ public boolean isManipulationStatement() {
+ return (Boolean)invoke(mn());
+ }
+
+ @SuppressWarnings("unchecked")
+ public Set<Object> getQuerySpaces() {
+ return (Set<Object>)invoke(mn());
+ }
+
+ public TypeStub[] getReturnTypes() {
+ Object[] returnTypes = (Object[])invoke(mn());
+ TypeStub[] res = new TypeStub[returnTypes.length];
+ for (int i = 0; i < returnTypes.length; i++) {
+ res[i] = TypeStubFactory.createTypeStub(returnTypes[i]);
+ }
+ return res;
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<String> collectSqlStrings() {
+ return (List<String>)invoke(mn());
+ }
+}
Modified:
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SessionFactoryStub.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SessionFactoryStub.java 2010-04-08
17:37:44 UTC (rev 21359)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SessionFactoryStub.java 2010-04-08
18:12:18 UTC (rev 21360)
@@ -7,16 +7,11 @@
import java.util.List;
import java.util.Map;
-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.base.HObject;
import org.hibernate.mediator.util.ELTransformer;
import org.hibernate.mediator.util.QLFormatHelper;
-import org.hibernate.type.Type;
-//TODO: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
public class SessionFactoryStub extends HObject {
public static final String CL = "org.hibernate.SessionFactory"; //$NON-NLS-1$
@@ -94,21 +89,18 @@
if (allowEL) {
query = ELTransformer.removeEL(query);
}
- new HQLQueryPlan(query, false, Collections.EMPTY_MAP,
- (SessionFactoryImpl) Obj());
+ HQLQueryPlanStub.newInstance(query, false, Collections.EMPTY_MAP, this);
}
}
public String generateSQL(String query) {
try {
- SessionFactoryImpl sfimpl = (SessionFactoryImpl) Obj(); // hack - to get to the
- // actual queries..
StringBuffer str = new StringBuffer(256);
- HQLQueryPlan plan = new HQLQueryPlan(query, false, Collections.EMPTY_MAP, sfimpl);
+ HQLQueryPlanStub plan = HQLQueryPlanStub.newInstance(query, false,
Collections.EMPTY_MAP, this);
- QueryTranslator[] translators = plan.getTranslators();
+ QueryTranslatorStub[] translators = plan.getTranslators();
for (int i = 0; i < translators.length; i++) {
- QueryTranslator translator = translators[i];
+ QueryTranslatorStub translator = translators[i];
if (translator.isManipulationStatement()) {
str.append(Messages.DynamicSQLPreviewView_manipulation_of + i
+ ":"); //$NON-NLS-1$
@@ -121,10 +113,10 @@
}
} else {
- Type[] returnTypes = translator.getReturnTypes();
+ TypeStub[] returnTypes = translator.getReturnTypes();
str.append(i + ": "); //$NON-NLS-1$
for (int j = 0; j < returnTypes.length; j++) {
- Type returnType = returnTypes[j];
+ TypeStub returnType = returnTypes[j];
str.append(returnType.getName());
if (j < returnTypes.length - 1) {
str.append(", ");} //$NON-NLS-1$
@@ -159,4 +151,16 @@
return msgs.toString();
}
}
+
+ public ClassMetadataStub getClassMetadata(String entityName) {
+ return new ClassMetadataStub(invoke(mn(), entityName));
+ }
+
+ public CollectionMetadataStub getCollectionMetadata(String roleName) {
+ return new CollectionMetadataStub(invoke(mn(), roleName));
+ }
+
+ public ClassMetadataStub getClassMetadata(Class<?> classWithoutInitializingProxy)
{
+ return new ClassMetadataStub(invoke(mn(), classWithoutInitializingProxy));
+ }
}
Modified:
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 2010-04-08
17:37:44 UTC (rev 21359)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/SessionStub.java 2010-04-08
18:12:18 UTC (rev 21360)
@@ -6,30 +6,18 @@
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.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.base.HObject;
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;
-// TODO: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
public class SessionStub extends HObject {
public static final String CL = "org.hibernate.Session"; //$NON-NLS-1$
@@ -46,7 +34,7 @@
if (isOpen()) {
try {
invoke(mn());
- } catch (HibernateException e) {
+ } catch (Exception e) {
exceptions.add(e);
}
}
@@ -57,57 +45,39 @@
return res;
}
+ public SessionFactoryStub getSessionFactory() {
+ return new SessionFactoryStub(invoke(mn()));
+ }
+
public boolean hasMetaData(Object obj) {
- SessionFactory sf = (SessionFactory)invoke("getSessionFactory");
//$NON-NLS-1$
+ SessionFactoryStub sf = getSessionFactory();
boolean res = sf.getClassMetadata(
- HibernateProxyHelper.getClassWithoutInitializingProxy(obj)) != null;
+ HibernateProxyHelperStub.getClassWithoutInitializingProxy(obj)) != null;
return res;
}
- public boolean hasMetaData(Object obj, List<Throwable> exceptions) {
- boolean res = false;
- try {
- SessionFactory sf = (SessionFactory)invoke("getSessionFactory");
//$NON-NLS-1$
- res = sf.getClassMetadata(
- HibernateProxyHelper.getClassWithoutInitializingProxy(obj)) != null;
- } catch (HibernateException e) {
- exceptions.add(e);
- }
- return res;
- }
-
public String getEntityName(Object obj) {
String res = (String)invoke(mn(), obj);
return res;
}
-
- public String getEntityName(Object obj, List<Throwable> exceptions) {
- String res = null;
- try {
- res = (String)invoke(mn(), obj);
- } catch (HibernateException e) {
- exceptions.add(e);
- }
- return res;
- }
public Object getPropertyValue(Object obj, Object id) {
Object pv = null;
- SessionFactory sf = (SessionFactory)invoke("getSessionFactory");
//$NON-NLS-1$
- ClassMetadata classMetadata;
+ SessionFactoryStub sf = getSessionFactory();
+ ClassMetadataStub classMetadata;
if (isOpen()) {
classMetadata = sf.getClassMetadata(getEntityName(obj));
} else {
- classMetadata = sf.getClassMetadata(HibernateProxyHelper
+ classMetadata = sf.getClassMetadata(HibernateProxyHelperStub
.getClassWithoutInitializingProxy(obj));
}
if (id.equals(classMetadata.getIdentifierPropertyName())) {
- pv = classMetadata.getIdentifier(obj, EntityMode.POJO);
+ pv = classMetadata.getIdentifier(obj, EntityModeStub.POJO);
} else {
- pv = classMetadata.getPropertyValue(obj, (String) id, EntityMode.POJO);
+ pv = classMetadata.getPropertyValue(obj, (String) id, EntityModeStub.POJO);
}
if (pv instanceof Collection<?>) {
- CollectionMetadata collectionMetadata = sf.getCollectionMetadata(classMetadata
+ CollectionMetadataStub collectionMetadata = sf.getCollectionMetadata(classMetadata
.getEntityName()
+ "." + id); //$NON-NLS-1$
if (collectionMetadata != null) {
@@ -118,18 +88,18 @@
}
public IPropertyDescriptor[] getPropertyDescriptors(final Object obj) {
- SessionFactory sf = (SessionFactory)invoke("getSessionFactory");
//$NON-NLS-1$
- ClassMetadata classMetadata;
+ SessionFactoryStub sf = getSessionFactory();
+ ClassMetadataStub classMetadata;
if (isOpen()) {
classMetadata = sf.getClassMetadata(getEntityName(obj));
} else {
- classMetadata = sf.getClassMetadata(HibernateProxyHelper
+ classMetadata = sf.getClassMetadata(HibernateProxyHelperStub
.getClassWithoutInitializingProxy(obj));
}
return initializePropertyDescriptors(classMetadata);
}
- protected IPropertyDescriptor[] initializePropertyDescriptors(ClassMetadata
classMetadata) {
+ protected IPropertyDescriptor[] initializePropertyDescriptors(ClassMetadataStub
classMetadata) {
String[] propertyNames = classMetadata.getPropertyNames();
int length = propertyNames.length;
@@ -173,8 +143,8 @@
long startTime = System.currentTimeMillis();
Object o = ip.eval(criteriaCode);
// ugly! TODO: make un-ugly!
- if (o instanceof Criteria) {
- Criteria criteria = (Criteria) o;
+ if (CriteriaStub.CL.equals(o.getClass().getName())) {
+ CriteriaStub criteria = new CriteriaStub(o);
if (maxResults != null) {
criteria.setMaxResults(maxResults.intValue());
}
@@ -191,23 +161,21 @@
queryTime.setTime(System.currentTimeMillis() - startTime);
} catch (EvalError e) {
exceptions.add(e);
- } catch (HibernateException e) {
+ } catch (Exception e) {
exceptions.add(e);
}
return res;
}
- @SuppressWarnings("unchecked")
- private Interpreter setupInterpreter() throws EvalError, HibernateException {
+ private Interpreter setupInterpreter() throws EvalError {
Interpreter interpreter = new Interpreter();
interpreter.set("session", Obj()); //$NON-NLS-1$
interpreter.setClassLoader(Thread.currentThread().getContextClassLoader());
- SessionImplementor si = (SessionImplementor)Obj();
- Map<String, ?> map = si.getFactory().getAllClassMetadata();
+ List<String> classes = getSessionFactory().getClasses();
- Iterator<String> iterator = map.keySet().iterator();
+ Iterator<String> iterator = classes.iterator();
// TODO: filter non classes.
String imports = ""; //$NON-NLS-1$
while (iterator.hasNext()) {
@@ -226,11 +194,9 @@
public List<Object> evalQuery(String queryString, QueryInputModel model, Time
queryTime,
List<Throwable> exceptions) {
List<Object> res = Collections.emptyList();
- Query query = null;
+ QueryStub query = null;
try {
- query = (Query)invoke("createQuery", queryString); //$NON-NLS-1$
- } catch (HibernateException e) {
- exceptions.add(e);
+ query = createQuery(queryString);
} catch (Exception e) {
exceptions.add(e);
}
@@ -248,15 +214,15 @@
Object element = iter.next();
res.add(element);
}
- } catch (HibernateException e) {
- exceptions.add(e);
} catch (IllegalArgumentException e) {
exceptions.add(e);
+ } catch (Exception e) {
+ exceptions.add(e);
}
return res;
}
- private void setupParameters(Query query, QueryInputModel model) {
+ private void setupParameters(QueryStub query, QueryInputModel model) {
if (model.getMaxResults() != null) {
query.setMaxResults(model.getMaxResults().intValue());
}
@@ -265,9 +231,9 @@
ConsoleQueryParameter parameter = qp[i];
try {
int pos = Integer.parseInt(parameter.getName());
- query.setParameter(pos, calcValue(parameter), (Type)parameter.getType().Obj());
+ query.setParameter(pos, calcValue(parameter), parameter.getType());
} catch (NumberFormatException nfe) {
- query.setParameter(parameter.getName(), calcValue(parameter),
(Type)parameter.getType().Obj());
+ query.setParameter(parameter.getName(), calcValue(parameter), parameter.getType());
}
}
}
@@ -275,15 +241,17 @@
private Object calcValue(ConsoleQueryParameter parameter) {
return parameter.getValueForQuery();
}
+
+ public QueryStub createQuery(String queryString) {
+ return new QueryStub(invoke(mn(), queryString));
+ }
public List<String> evalQueryPathNames(String queryString, QueryInputModel model,
List<Throwable> exceptions) {
List<String> res = Collections.emptyList();
- Query query = null;
+ QueryStub query = null;
try {
- query = (Query)invoke("createQuery", queryString); //$NON-NLS-1$
- } catch (HibernateException e) {
- exceptions.add(e);
+ query = createQuery(queryString);
} catch (Exception e) {
exceptions.add(e);
}
@@ -298,16 +266,16 @@
// ignore -
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2188
}
if (returnAliases == null) {
- Type[] t;
+ TypeStub[] t;
try {
t = query.getReturnTypes();
} catch (NullPointerException npe) {
- t = new Type[] { null };
+ t = new TypeStub[] { 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];
+ TypeStub type = t[i];
if (type == null) {
res.add("<multiple types>"); //$NON-NLS-1$
} else {
@@ -321,7 +289,7 @@
res.add(t[i]);
}
}
- } catch (HibernateException e) {
+ } catch (Exception e) {
exceptions.add(e);
}
return res;
Modified:
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 2010-04-08
17:37:44 UTC (rev 21359)
+++
branches/hibernatetools-multiversion/hibernatetools/plugins/org.hibernate.mediator/src/org/hibernate/mediator/stubs/TypeStubFactory.java 2010-04-08
18:12:18 UTC (rev 21360)
@@ -15,6 +15,12 @@
// return new TypeStub(value);
} else if (ClassHelper.isClassOrOffspring(cl, EntityTypeStub.CL)) {
return new EntityTypeStub(value);
+ } else if (ClassHelper.isClassOrOffspring(cl, IntegerTypeStub.CL)) {
+ return new IntegerTypeStub(value);
+ } else if (ClassHelper.isClassOrOffspring(cl, PrimitiveTypeStub.CL)) {
+ return new PrimitiveTypeStub(value);
+ } else if (ClassHelper.isClassOrOffspring(cl, ImmutableTypeStub.CL)) {
+ return new ImmutableTypeStub(value);
} else if (ClassHelper.isClassOrOffspring(cl, NullableTypeStub.CL)) {
return new NullableTypeStub(value);
}
Modified:
branches/hibernatetools-multiversion/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/hbmexporter/HbmExporterTest.java
===================================================================
---
branches/hibernatetools-multiversion/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/hbmexporter/HbmExporterTest.java 2010-04-08
17:37:44 UTC (rev 21359)
+++
branches/hibernatetools-multiversion/hibernatetools/tests/org.hibernate.eclipse.jdt.ui.test/src/org/hibernate/eclipse/jdt/ui/test/hbmexporter/HbmExporterTest.java 2010-04-08
18:12:18 UTC (rev 21360)
@@ -166,7 +166,7 @@
value.getClass()==ListStub.class);
ListStub list = (ListStub)value;
assertTrue(list.getElement() instanceof OneToManyStub);
- assertTrue(list.getCollectionTable().equals(b.getTable()));
+ assertTrue(list.getCollectionTable().Obj().equals(b.getTable().Obj()));
assertNotNull(list.getIndex());
assertNotNull(list.getKey());
}
@@ -184,7 +184,7 @@
value.getClass()==SetStub.class);
SetStub set = (SetStub)value;
assertTrue(set.getElement() instanceof OneToManyStub);
- assertTrue(set.getCollectionTable().equals(b.getTable()));
+ assertTrue(set.getCollectionTable().Obj().equals(b.getTable().Obj()));
assertNotNull(set.getKey());
}
@@ -201,7 +201,7 @@
value.getClass()==MapStub.class);
MapStub map = (MapStub)value;
assertTrue(map.getElement() instanceof OneToManyStub);
- assertTrue(map.getCollectionTable().equals(b.getTable()));
+ assertTrue(map.getCollectionTable().Obj().equals(b.getTable().Obj()));
assertNotNull(map.getKey());
assertEquals("string", map.getKey().getType().getName()); //$NON-NLS-1$
}