[Jboss-cvs] JBossAS SVN: r55926 - in branches/JBoss_3_2_7_CP: server/src/main/org/jboss/ejb/plugins/cmp/ejbql server/src/main/org/jboss/ejb/plugins/cmp/jdbc testsuite/src/main/org/jboss/test/cmp2/enum/ejb testsuite/src/main/org/jboss/test/cmp2/enum/test testsuite/src/main/org/jboss/test/cmp2/keygen/test testsuite/src/resources/cmp2/enum/META-INF testsuite/src/resources/cmp2/keygen/META-INF
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Aug 14 21:29:50 EDT 2006
Author: ryan.campbell at jboss.com
Date: 2006-08-14 21:29:48 -0400 (Mon, 14 Aug 2006)
New Revision: 55926
Modified:
branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/ejbql/JBossQLParser.jjt
branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/QueryParameter.java
branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
branches/JBoss_3_2_7_CP/testsuite/src/main/org/jboss/test/cmp2/enum/ejb/ChildCMPBean.java
branches/JBoss_3_2_7_CP/testsuite/src/main/org/jboss/test/cmp2/enum/ejb/FacadeSessionBean.java
branches/JBoss_3_2_7_CP/testsuite/src/main/org/jboss/test/cmp2/enum/test/EnumUnitTestCase.java
branches/JBoss_3_2_7_CP/testsuite/src/main/org/jboss/test/cmp2/keygen/test/KeyGenerationUnitTestCase.java
branches/JBoss_3_2_7_CP/testsuite/src/resources/cmp2/enum/META-INF/ejb-jar.xml
branches/JBoss_3_2_7_CP/testsuite/src/resources/cmp2/enum/META-INF/jbosscmp-jdbc.xml
branches/JBoss_3_2_7_CP/testsuite/src/resources/cmp2/keygen/META-INF/ejb-jar.xml
Log:
merged JBAS-2514: support for <, <=, > and >= comparisons for types mapped with user-type-mapping
Modified: branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/ejbql/JBossQLParser.jjt
===================================================================
--- branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/ejbql/JBossQLParser.jjt 2006-08-15 00:32:06 UTC (rev 55925)
+++ branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/ejbql/JBossQLParser.jjt 2006-08-15 01:29:48 UTC (rev 55926)
@@ -449,11 +449,15 @@
DatetimeExpression()
) #DatetimeComparison
|
- LOOKAHEAD(ValueClassValue() ( <EQ> | <NE> ) )
+ LOOKAHEAD(ValueClassValue() ( <EQ> | <GT> | <GE> | <LT> | <LE> | <NE> ) )
(
ValueClassValue()
(
<EQ> { jjtThis.opp="="; } |
+ <GT> { jjtThis.opp=">"; } |
+ <GE> { jjtThis.opp=">="; } |
+ <LT> { jjtThis.opp="<"; } |
+ <LE> { jjtThis.opp="<="; } |
<NE> { jjtThis.opp="<>"; }
)
ValueClassExpression()
Modified: branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java
===================================================================
--- branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java 2006-08-15 00:32:06 UTC (rev 55925)
+++ branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCEJBQLCompiler.java 2006-08-15 01:29:48 UTC (rev 55926)
@@ -1,10 +1,24 @@
/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
+* 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.jboss.ejb.plugins.cmp.jdbc;
import java.io.StringReader;
@@ -1300,10 +1314,12 @@
StringBuffer buf = (StringBuffer) data;
boolean not = (node.opp.equals(SQLUtil.NOT_EQUAL));
+ String comparison = node.opp;
buf.append('(');
if(not)
{
buf.append(SQLUtil.NOT).append('(');
+ comparison = "=";
}
// setup the from path
@@ -1328,7 +1344,7 @@
}
inputParameters.addAll(QueryParameter.createParameters(toParam.number - 1, fromCMPField));
- SQLUtil.getWhereClause(fromCMPField.getJDBCType(), fromAlias, buf);
+ SQLUtil.getWhereClause(fromCMPField.getJDBCType(), fromAlias, comparison, buf);
}
else
{
@@ -1346,7 +1362,7 @@
" to CMP field=" + toCMPField.getFieldType());
}
- SQLUtil.getSelfCompareWhereClause(fromCMPField, toCMPField, fromAlias, toAlias, buf);
+ SQLUtil.getSelfCompareWhereClause(fromCMPField, toCMPField, fromAlias, toAlias, comparison, buf);
}
return (not ? buf.append(')') : buf).append(')');
Modified: branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java
===================================================================
--- branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java 2006-08-15 00:32:06 UTC (rev 55925)
+++ branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/JDBCTypeFactory.java 2006-08-15 01:29:48 UTC (rev 55926)
@@ -1,10 +1,24 @@
/*
- * JBoss, the OpenSource J2EE webOS
+ * 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.
*
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
+ * 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.jboss.ejb.plugins.cmp.jdbc;
import java.lang.reflect.Method;
@@ -29,7 +43,7 @@
import org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCUserTypeMappingMetaData;
import org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCMappingMetaData;
import org.jboss.deployment.DeploymentException;
-import org.jboss.logging.Logger;
+//import org.jboss.logging.Logger;
/**
* JDBCTypeFactory mapps Java Classes to JDBCType objects. The main job of
@@ -41,7 +55,7 @@
*/
public final class JDBCTypeFactory
{
- private static final Logger log = Logger.getLogger(JDBCTypeFactory.class);
+ //private static final Logger log = Logger.getLogger(JDBCTypeFactory.class);
//
// Default CMPFieldStateFactory implementations
@@ -394,8 +408,31 @@
JDBCTypeSimple type = (JDBCTypeSimple)mappedSimpleTypes.get(javaType);
if(type == null)
{
- log.warn("Type not mapped: " + javaType.getName());
+ JDBCUserTypeMappingMetaData userTypeMapping =
+ (JDBCUserTypeMappingMetaData)userTypeMappings.get(javaType.getName());
+ Mapper mapper = null;
+ if(userTypeMapping != null)
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ javaType = cl.loadClass(userTypeMapping.getMappedType());
+ }
+ catch(ClassNotFoundException e)
+ {
+ throw new IllegalStateException("Failed to load mapped type: " + userTypeMapping.getMappedType());
+ }
+ try
+ {
+ mapper = (Mapper)newInstance(userTypeMapping.getMapper());
+ }
+ catch(DeploymentException e)
+ {
+ throw new IllegalStateException("Failed to create Mapper instance of " + userTypeMapping.getMapper());
+ }
+ }
+
JDBCMappingMetaData typeMappingMD = typeMapping.getTypeMappingMetaData(javaType);
String sqlType = typeMappingMD.getSqlType();
int jdbcType = typeMappingMD.getJdbcType();
@@ -437,7 +474,7 @@
}
type = new JDBCTypeSimple(
- null, javaType, jdbcType, sqlType, notNull, autoIncrement, null, paramSetter, resultReader
+ null, javaType, jdbcType, sqlType, notNull, autoIncrement, mapper, paramSetter, resultReader
);
}
return type;
Modified: branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/QueryParameter.java
===================================================================
--- branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/QueryParameter.java 2006-08-15 00:32:06 UTC (rev 55925)
+++ branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/QueryParameter.java 2006-08-15 01:29:48 UTC (rev 55926)
@@ -1,8 +1,23 @@
/*
- * JBoss, the OpenSource J2EE webOS
+ * 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.
*
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
+ * 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.jboss.ejb.plugins.cmp.jdbc;
@@ -53,6 +68,7 @@
null,
null,
type.getJDBCTypes()[0]);
+ param.type = type;
parameters = Collections.singletonList(param);
}
return parameters;
@@ -90,6 +106,7 @@
pkField,
null,
type.getJDBCTypes()[0]);
+ param.type = type;
parameters.add(param);
}
}
@@ -127,6 +144,7 @@
pkField,
null,
type.getJDBCTypes()[0]);
+ param.type = type;
parameters.add(param);
}
}
@@ -140,6 +158,7 @@
private final String parameterString;
private int jdbcType;
+ private JDBCType type;
public QueryParameter(
JDBCEntityPersistenceStore manager,
@@ -218,6 +237,7 @@
"dependent value class, so a properties cannot supplied.");
}
jdbcType = type.getJDBCTypes()[0];
+ this.type = type;
}
else
{
@@ -304,7 +324,15 @@
}
else
{
- param = JDBCUtil.getParameterSetter(jdbcType, arg == null ? null : arg.getClass());
+ if(type != null)
+ {
+ arg = type.getColumnValue(0, arg);
+ param = type.getParameterSetter()[0];
+ }
+ else
+ {
+ param = JDBCUtil.getParameterSetter(jdbcType, arg == null ? null : arg.getClass());
+ }
}
param.set(ps, index, jdbcType, arg, log);
Modified: branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java
===================================================================
--- branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java 2006-08-15 00:32:06 UTC (rev 55925)
+++ branches/JBoss_3_2_7_CP/server/src/main/org/jboss/ejb/plugins/cmp/jdbc/SQLUtil.java 2006-08-15 01:29:48 UTC (rev 55926)
@@ -1,10 +1,24 @@
/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
+* 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.jboss.ejb.plugins.cmp.jdbc;
import java.sql.Connection;
@@ -613,7 +627,29 @@
return buf;
}
+ /**
+ * Returns identifier.columnName0{comparison}?
+ * [AND identifier.columnName1{comparison}?
+ * [AND identifier.columnName2{comparison}? [...]]]
+ */
+ public static StringBuffer getWhereClause(JDBCType type, String identifier, String comparison, StringBuffer buf)
+ {
+ if(identifier.length() > 0)
+ {
+ identifier += '.';
+ }
+ String[] columnNames = type.getColumnNames();
+ buf.append(identifier).append(columnNames[0]).append(comparison).append('?');
+ int i = 1;
+ while(i < columnNames.length)
+ {
+ buf.append(AND).append(identifier).append(columnNames[i++]).append(comparison).append('?');
+ }
+ return buf;
+ }
+
+
// =======================================================================
// Is [Not] Null Clause
// columnName0 IS [NOT] NULL [AND columnName1 IS [NOT] NULL [...]]
@@ -908,10 +944,11 @@
JDBCFieldBridge toField,
String fromIdentifier,
String toIdentifier,
+ String comparison,
StringBuffer buf)
{
return getSelfCompareWhereClause(
- fromField.getJDBCType(), toField.getJDBCType(), fromIdentifier, toIdentifier, buf
+ fromField.getJDBCType(), toField.getJDBCType(), fromIdentifier, toIdentifier, comparison, buf
);
}
@@ -919,6 +956,7 @@
JDBCType toType,
String fromIdentifier,
String toIdentifier,
+ String comparison,
StringBuffer buf)
{
if(fromIdentifier.length() > 0)
@@ -931,7 +969,7 @@
buf.append(fromIdentifier)
.append(fromColumnNames[0])
- .append('=')
+ .append(comparison)
.append(toIdentifier)
.append(toColumnNames[0]);
int i = 1;
@@ -940,7 +978,7 @@
buf.append(AND)
.append(fromIdentifier)
.append(fromColumnNames[i])
- .append('=')
+ .append(comparison)
.append(toIdentifier)
.append(toColumnNames[i++]);
}
Modified: branches/JBoss_3_2_7_CP/testsuite/src/main/org/jboss/test/cmp2/enum/ejb/ChildCMPBean.java
===================================================================
--- branches/JBoss_3_2_7_CP/testsuite/src/main/org/jboss/test/cmp2/enum/ejb/ChildCMPBean.java 2006-08-15 00:32:06 UTC (rev 55925)
+++ branches/JBoss_3_2_7_CP/testsuite/src/main/org/jboss/test/cmp2/enum/ejb/ChildCMPBean.java 2006-08-15 01:29:48 UTC (rev 55926)
@@ -1,8 +1,23 @@
/*
- * JBoss, the OpenSource J2EE webOS
+ * 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.
*
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
+ * 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.jboss.test.cmp2.enum.ejb;
@@ -30,8 +45,23 @@
* remove-table="${jboss.remove.table}"
* @ejb:transaction-type type="Container"
*
+ * @ejb.finder
+ * signature="org.jboss.test.cmp2.ejb.ChildLocal findByColor(org.jboss.test.cmp2.enum.ejb.ColorEnum color)"
+ * query="select object(o) from Child o where o.color=?1"
+ *
+ * @ejb.finder
+ * signature="org.jboss.test.cmp2.ejb.ChildLocal findByColorDeclaredSql(org.jboss.test.cmp2.enum.ejb.ColorEnum color)"
+ * query="select object(o) from Child o where o.color=?1"
+ *
+ * @ejb.finder
+ * signature="java.util.Collection findLowColor(org.jboss.test.cmp2.enum.ejb.ColorEnum color)"
+ * query="select object(o) from Child o where o.color<?1"
+ * @jboss.query
+ * signature="java.util.Collection findLowColor(org.jboss.test.cmp2.enum.ejb.ColorEnum color)"
+ * query="select object(o) from Child o where o.color<?1"
+ *
* @author <a href="mailto:alex at jboss.org">Alex Loubyansky</a>
- + * @author <a href="mailto:gturner at unzane.com">Gerald Turner</a>
+ * @author <a href="mailto:gturner at unzane.com">Gerald Turner</a>
*/
public abstract class ChildCMPBean
implements EntityBean
Modified: branches/JBoss_3_2_7_CP/testsuite/src/main/org/jboss/test/cmp2/enum/ejb/FacadeSessionBean.java
===================================================================
--- branches/JBoss_3_2_7_CP/testsuite/src/main/org/jboss/test/cmp2/enum/ejb/FacadeSessionBean.java 2006-08-15 00:32:06 UTC (rev 55925)
+++ branches/JBoss_3_2_7_CP/testsuite/src/main/org/jboss/test/cmp2/enum/ejb/FacadeSessionBean.java 2006-08-15 01:29:48 UTC (rev 55926)
@@ -1,15 +1,37 @@
/*
- * JBoss, the OpenSource J2EE webOS
+ * 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.
*
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
+ * 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.jboss.test.cmp2.enum.ejb;
+import java.util.Collection;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.ejb.CreateException;
+import org.jboss.test.cmp2.enum.ejb.ChildLocal;
+import org.jboss.test.cmp2.enum.ejb.ChildUtil;
+
/**
* @ejb:bean
* type="Stateless"
@@ -82,6 +104,42 @@
ChildUtil.getLocalHome().remove(childId);
}
+ /**
+ * @ejb.interface-method
+ */
+ public IDClass findByColor(ColorEnum color)
+ throws Exception
+ {
+ ChildLocal child = ChildUtil.getLocalHome().findByColor(color);
+ return child.getId();
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public IDClass findByColorDeclaredSql(ColorEnum color)
+ throws Exception
+ {
+ ChildLocal child = ChildUtil.getLocalHome().findByColorDeclaredSql(color);
+ return child.getId();
+ }
+
+ /**
+ * @ejb.interface-method
+ */
+ public List findLowColor(ColorEnum color)
+ throws Exception
+ {
+ Collection children = ChildUtil.getLocalHome().findLowColor(color);
+ List ids = new ArrayList(children.size());
+ for(Iterator i = children.iterator(); i.hasNext();)
+ {
+ ChildLocal child = (ChildLocal)i.next();
+ ids.add(child.getId());
+ }
+ return ids;
+ }
+
// SessionBean implementation
/**
Modified: branches/JBoss_3_2_7_CP/testsuite/src/main/org/jboss/test/cmp2/enum/test/EnumUnitTestCase.java
===================================================================
--- branches/JBoss_3_2_7_CP/testsuite/src/main/org/jboss/test/cmp2/enum/test/EnumUnitTestCase.java 2006-08-15 00:32:06 UTC (rev 55925)
+++ branches/JBoss_3_2_7_CP/testsuite/src/main/org/jboss/test/cmp2/enum/test/EnumUnitTestCase.java 2006-08-15 01:29:48 UTC (rev 55926)
@@ -6,6 +6,7 @@
*/
package org.jboss.test.cmp2.enum.test;
+import java.util.List;
import net.sourceforge.junitejb.EJBTestCase;
import junit.framework.Test;
import org.jboss.test.JBossTestCase;
@@ -62,4 +63,59 @@
assertTrue(AnimalEnum.CAT == facade.getAnimalForId(childId));
facade.removeChild(childId);
}
+
+ public void testFindByColor()
+ throws Exception
+ {
+ Facade facade = FacadeUtil.getHome().create();
+ IDClass childId = new IDClass(3);
+ facade.createChild(childId);
+ try
+ {
+ facade.setColor(childId, ColorEnum.BLUE);
+ IDClass id = facade.findByColor(ColorEnum.BLUE);
+ assertEquals(childId, id);
+ }
+ finally
+ {
+ facade.removeChild(childId);
+ }
+ }
+
+ public void testFindByColorDeclaredSql()
+ throws Exception
+ {
+ Facade facade = FacadeUtil.getHome().create();
+ IDClass childId = new IDClass(4);
+ facade.createChild(childId);
+ try
+ {
+ facade.setColor(childId, ColorEnum.BLUE);
+ IDClass id = facade.findByColorDeclaredSql(ColorEnum.BLUE);
+ assertEquals(childId, id);
+ }
+ finally
+ {
+ facade.removeChild(childId);
+ }
+ }
+
+ public void testLowColor()
+ throws Exception
+ {
+ Facade facade = FacadeUtil.getHome().create();
+ IDClass childId = new IDClass(3);
+ facade.createChild(childId);
+ try
+ {
+ facade.setColor(childId, ColorEnum.RED);
+ List ids = facade.findLowColor(ColorEnum.BLUE);
+ assertEquals(1, ids.size());
+ assertEquals(childId, ids.get(0));
+ }
+ finally
+ {
+ facade.removeChild(childId);
+ }
+ }
}
Modified: branches/JBoss_3_2_7_CP/testsuite/src/main/org/jboss/test/cmp2/keygen/test/KeyGenerationUnitTestCase.java
===================================================================
--- branches/JBoss_3_2_7_CP/testsuite/src/main/org/jboss/test/cmp2/keygen/test/KeyGenerationUnitTestCase.java 2006-08-15 00:32:06 UTC (rev 55925)
+++ branches/JBoss_3_2_7_CP/testsuite/src/main/org/jboss/test/cmp2/keygen/test/KeyGenerationUnitTestCase.java 2006-08-15 01:29:48 UTC (rev 55926)
@@ -18,7 +18,7 @@
import org.jboss.test.cmp2.keygen.ejb.UnknownPKLocal;
import org.jboss.test.cmp2.keygen.ejb.UnknownPKLocalHome;
import org.jboss.test.cmp2.keygen.ejb.IntegerPKLocalHome;
-import org.jboss.test.util.ejb.EJBTestCase;
+import net.sourceforge.junitejb.EJBTestCase;
/** Tests of the entity-command key generation
*
Modified: branches/JBoss_3_2_7_CP/testsuite/src/resources/cmp2/enum/META-INF/ejb-jar.xml
===================================================================
--- branches/JBoss_3_2_7_CP/testsuite/src/resources/cmp2/enum/META-INF/ejb-jar.xml 2006-08-15 00:32:06 UTC (rev 55925)
+++ branches/JBoss_3_2_7_CP/testsuite/src/resources/cmp2/enum/META-INF/ejb-jar.xml 2006-08-15 01:29:48 UTC (rev 55926)
@@ -51,6 +51,34 @@
<field-name>animal</field-name>
</cmp-field>
<primkey-field>id</primkey-field>
+
+ <query>
+ <query-method>
+ <method-name>findByColor</method-name>
+ <method-params>
+ <method-param>org.jboss.test.cmp2.enum.ejb.ColorEnum</method-param>
+ </method-params>
+ </query-method>
+ <ejb-ql>select object(o) from Child o where o.color=?1</ejb-ql>
+ </query>
+ <query>
+ <query-method>
+ <method-name>findByColorDeclaredSql</method-name>
+ <method-params>
+ <method-param>org.jboss.test.cmp2.enum.ejb.ColorEnum</method-param>
+ </method-params>
+ </query-method>
+ <ejb-ql>select object(o) from Child o where o.color=?1</ejb-ql>
+ </query>
+ <query>
+ <query-method>
+ <method-name>findLowColor</method-name>
+ <method-params>
+ <method-param>org.jboss.test.cmp2.enum.ejb.ColorEnum</method-param>
+ </method-params>
+ </query-method>
+ <ejb-ql><![CDATA[select object(o) from Child o where o.color < ?1]]></ejb-ql>
+ </query>
</entity>
</enterprise-beans>
Modified: branches/JBoss_3_2_7_CP/testsuite/src/resources/cmp2/enum/META-INF/jbosscmp-jdbc.xml
===================================================================
--- branches/JBoss_3_2_7_CP/testsuite/src/resources/cmp2/enum/META-INF/jbosscmp-jdbc.xml 2006-08-15 00:32:06 UTC (rev 55925)
+++ branches/JBoss_3_2_7_CP/testsuite/src/resources/cmp2/enum/META-INF/jbosscmp-jdbc.xml 2006-08-15 01:29:48 UTC (rev 55926)
@@ -20,6 +20,39 @@
<field-name>animal</field-name>
<column-name>ANIMAL_ID</column-name>
</cmp-field>
+
+ <query>
+ <query-method>
+ <method-name>findByColor</method-name>
+ <method-params>
+ <method-param>org.jboss.test.cmp2.enum.ejb.ColorEnum</method-param>
+ </method-params>
+ </query-method>
+ <jboss-ql>select object(o) from Child o where o.color=?1</jboss-ql>
+ </query>
+ <query>
+ <query-method>
+ <method-name>findByColorDeclaredSql</method-name>
+ <method-params>
+ <method-param>org.jboss.test.cmp2.enum.ejb.ColorEnum</method-param>
+ </method-params>
+ </query-method>
+ <declared-sql>
+ <select>
+ <distinct/>
+ </select>
+ <where>COLOR_ID = {0}</where>
+ </declared-sql>
+ </query>
+ <query>
+ <query-method>
+ <method-name>findLowColor</method-name>
+ <method-params>
+ <method-param>org.jboss.test.cmp2.enum.ejb.ColorEnum</method-param>
+ </method-params>
+ </query-method>
+ <jboss-ql><![CDATA[select object(o) from Child o where o.color < ?1]]></jboss-ql>
+ </query>
</entity>
</enterprise-beans>
Modified: branches/JBoss_3_2_7_CP/testsuite/src/resources/cmp2/keygen/META-INF/ejb-jar.xml
===================================================================
--- branches/JBoss_3_2_7_CP/testsuite/src/resources/cmp2/keygen/META-INF/ejb-jar.xml 2006-08-15 00:32:06 UTC (rev 55925)
+++ branches/JBoss_3_2_7_CP/testsuite/src/resources/cmp2/keygen/META-INF/ejb-jar.xml 2006-08-15 01:29:48 UTC (rev 55926)
@@ -8,9 +8,9 @@
<session>
<description>JUnit Session Bean Test Runner</description>
<ejb-name>EJBTestRunnerEJB</ejb-name>
- <home>org.jboss.test.util.ejb.EJBTestRunnerHome</home>
- <remote>org.jboss.test.util.ejb.EJBTestRunner</remote>
- <ejb-class>org.jboss.test.util.ejb.EJBTestRunnerBean</ejb-class>
+ <home>net.sourceforge.junitejb.EJBTestRunnerHome</home>
+ <remote>net.sourceforge.junitejb.EJBTestRunner</remote>
+ <ejb-class>net.sourceforge.junitejb.EJBTestRunnerBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
<ejb-local-ref>
More information about the jboss-cvs-commits
mailing list