Author: jgbutler
Date: Wed Jan 7 08:16:31 2009
New Revision: 732380
URL: http://svn.apache.org/viewvc?rev=732380&view=rev
Log:
[Ibator] Fix for NPE when DAOs are not generated
Modified:
ibatis/trunk/java/tools/ibator/core/build/version.properties
ibatis/trunk/java/tools/ibator/core/doc/ReleaseNotes.txt
ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IntrospectedTable.java
ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/execute/miscellaneous/BaseMiscellaneousTest.java
ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/execute/miscellaneous/MiscellaneousTests.java
ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/ibatorConfig.xml
Modified: ibatis/trunk/java/tools/ibator/core/build/version.properties
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/build/version.properties?rev=732380&r1=732379&r2=732380&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/build/version.properties (original)
+++ ibatis/trunk/java/tools/ibator/core/build/version.properties Wed Jan 7
08:16:31 2009
@@ -1,4 +1,4 @@
#Ibator build version info
-#Thu Jan 01 19:08:47 CST 2009
-version=1.2.1
-buildNum=696
+#Wed Jan 07 10:10:05 CST 2009
+version=1.2.2
+buildNum=700
Modified: ibatis/trunk/java/tools/ibator/core/doc/ReleaseNotes.txt
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/doc/ReleaseNotes.txt?rev=732380&r1=732379&r2=732380&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/doc/ReleaseNotes.txt (original)
+++ ibatis/trunk/java/tools/ibator/core/doc/ReleaseNotes.txt Wed Jan 7
08:16:31 2009
@@ -1,6 +1,9 @@
-------------------------------------------------------------------------------
Version 1.2.2:
+Bugs:
+1. Fixed NPE when no DAOs are generated
+
Enhancements:
1. IBATIS-569 - Make it easier to override IbatorRules in plugins
2. IBATIS-571 - Added "autoDelimitKeywords" support to <ibatorContext>
Modified: ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html?rev=732380&r1=732379&r2=732380&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html (original)
+++ ibatis/trunk/java/tools/ibator/core/htmldoc/whatsNew.html Wed Jan 7
08:16:31 2009
@@ -19,6 +19,7 @@
<h2>Version 1.2.2</h2>
<h3>Bugs Fixed</h3>
<ul>
+ <li>NPE when no DAOs are generated.</li>
</ul>
<h3>Enhancements</h3>
Modified:
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IntrospectedTable.java
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IntrospectedTable.java?rev=732380&r1=732379&r2=732380&view=diff
==============================================================================
---
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IntrospectedTable.java
(original)
+++
ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/api/IntrospectedTable.java
Wed Jan 7 08:16:31 2009
@@ -48,24 +48,36 @@
*/
public abstract class IntrospectedTable {
/**
- * This attribute must be a class of type java.lang.String
+ * This attribute must be a class of type java.lang.String.
+ * <p/>
+ * Note: this attribute will not be set if DAOs
+ * are not being generated for this table.
*/
public static final String ATTR_DAO_IMPLEMENTATION_PACKAGE =
"org.apache.ibatis.ibator.api.IntrospectedTable.ATTR_DAO_IMPLEMENTATION_PACKAGE";
//$NON-NLS-1$
/**
* This attribute must be a class of type java.lang.String
+ * <p/>
+ * Note: this attribute will not be set if DAOs
+ * are not being generated for this table.
*/
public static final String ATTR_DAO_INTERFACE_PACKAGE =
"org.apache.ibatis.ibator.api.IntrospectedTable.ATTR_DAO_INTERFACE_PACKAGE";
//$NON-NLS-1$
/**
* This attribute must be a class of type
* org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType
+ * <p/>
+ * Note: this attribute will not be set if DAOs
+ * are not being generated for this table.
*/
public static final String ATTR_DAO_IMPLEMENTATION_TYPE =
"org.apache.ibatis.ibator.api.IntrospectedTable.ATTR_DAO_IMPLEMENTATION_TYPE";
//$NON-NLS-1$
/**
* This attribute must be a class of type
* org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType
+ * <p/>
+ * Note: this attribute will not be set if DAOs
+ * are not being generated for this table.
*/
public static final String ATTR_DAO_INTERFACE_TYPE =
"org.apache.ibatis.ibator.api.IntrospectedTable.ATTR_DAO_INTERFACE_TYPE";
//$NON-NLS-1$
@@ -503,6 +515,9 @@
private void calculateDAOImplementationPackage() {
DAOGeneratorConfiguration config =
ibatorContext.getDaoGeneratorConfiguration();
+ if (config == null) {
+ return;
+ }
StringBuilder sb = new StringBuilder();
if (StringUtility.stringHasValue(config.getImplementationPackage())) {
@@ -519,6 +534,9 @@
private void calculateDAOInterfacePackage() {
DAOGeneratorConfiguration config =
ibatorContext.getDaoGeneratorConfiguration();
+ if (config == null) {
+ return;
+ }
StringBuilder sb = new StringBuilder();
sb.append(config.getTargetPackage());
@@ -530,6 +548,10 @@
}
private void calculateDAOImplementationType() {
+ if (ibatorContext.getDaoGeneratorConfiguration() == null) {
+ return;
+ }
+
StringBuilder sb = new StringBuilder();
sb.append(getDAOImplementationPackage());
sb.append('.');
@@ -542,6 +564,10 @@
}
private void calculateDAOInterfaceType() {
+ if (ibatorContext.getDaoGeneratorConfiguration() == null) {
+ return;
+ }
+
StringBuilder sb = new StringBuilder();
sb.append(getDAOInterfacePackage());
sb.append('.');
Modified:
ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/execute/miscellaneous/BaseMiscellaneousTest.java
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/execute/miscellaneous/BaseMiscellaneousTest.java?rev=732380&r1=732379&r2=732380&view=diff
==============================================================================
---
ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/execute/miscellaneous/BaseMiscellaneousTest.java
(original)
+++
ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/execute/miscellaneous/BaseMiscellaneousTest.java
Wed Jan 7 08:16:31 2009
@@ -1,11 +1,9 @@
package ibatortest.execute.miscellaneous;
import ibatortest.BaseTest;
-import ibatortest.generated.miscellaneous.dao.AnotherawfultableDAO;
import ibatortest.generated.miscellaneous.dao.MyObjectDAO;
-import ibatortest.generated.miscellaneous.dao.impl.AnotherawfultableDAOImpl;
-import ibatortest.generated.miscellaneous.dao.impl.MyObjectDAOImpl;
import ibatortest.generated.miscellaneous.dao.RegexrenameDAO;
+import ibatortest.generated.miscellaneous.dao.impl.MyObjectDAOImpl;
import ibatortest.generated.miscellaneous.dao.impl.RegexrenameDAOImpl;
public class BaseMiscellaneousTest extends BaseTest {
@@ -25,9 +23,4 @@
RegexrenameDAOImpl dao = new RegexrenameDAOImpl(getSqlMapClient());
return dao;
}
-
- protected AnotherawfultableDAO getAnotherawfultableDAO() {
- AnotherawfultableDAO dao = new
AnotherawfultableDAOImpl(getSqlMapClient());
- return dao;
- }
}
Modified:
ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/execute/miscellaneous/MiscellaneousTests.java
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/execute/miscellaneous/MiscellaneousTests.java?rev=732380&r1=732379&r2=732380&view=diff
==============================================================================
---
ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/execute/miscellaneous/MiscellaneousTests.java
(original)
+++
ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/execute/miscellaneous/MiscellaneousTests.java
Wed Jan 7 08:16:31 2009
@@ -31,7 +31,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import ibatortest.generated.miscellaneous.dao.AnotherawfultableDAO;
import ibatortest.generated.miscellaneous.dao.MyObjectDAO;
import ibatortest.generated.miscellaneous.dao.RegexrenameDAO;
import ibatortest.generated.miscellaneous.model.Anotherawfultable;
@@ -45,6 +44,8 @@
import java.util.Date;
import java.util.List;
+import com.ibatis.sqlmap.client.SqlMapClient;
+
/**
* @author Jeff Butler
*
@@ -894,7 +895,7 @@
}
public void testAnotherAwfulTableInsert() {
- AnotherawfultableDAO dao = getAnotherawfultableDAO();
+ SqlMapClient sqlMap = getSqlMapClient();
try {
Anotherawfultable record = new Anotherawfultable();
@@ -902,9 +903,14 @@
record.setSelect("select");
record.setInsert("insert");
- dao.insertAnotherawfultable(record);
+ sqlMap.insert("ANOTHERAWFULTABLE.ibatorgenerated_insert", record);
+
+ Anotherawfultable key = new Anotherawfultable();
+ key.setId(5);
- Anotherawfultable returnedRecord =
dao.selectAnotherawfultableByPrimaryKey(5);
+ Anotherawfultable returnedRecord = (Anotherawfultable)
+
sqlMap.queryForObject("ANOTHERAWFULTABLE.ibatorgenerated_selectByPrimaryKey",
+ key);
assertEquals(record.getId(), returnedRecord.getId());
assertEquals(record.getSelect(), returnedRecord.getSelect());
Modified:
ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/ibatorConfig.xml
URL:
http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/ibatorConfig.xml?rev=732380&r1=732379&r2=732380&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/ibatorConfig.xml
(original)
+++ ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/ibatorConfig.xml
Wed Jan 7 08:16:31 2009
@@ -260,8 +260,6 @@
</ibatorContext>
<ibatorContext id="miscellaneousTests" targetRuntime="Ibatis2Java5">
- <property name="autoDelimitKeywords" value="true"/>
-
<ibatorPlugin type="org.apache.ibatis.ibator.plugins.EqualsHashCodePlugin"
/>
<ibatorPlugin
type="org.apache.ibatis.ibator.plugins.RenameExampleClassPlugin" >
<property name="searchString" value="Example$"/>
@@ -306,6 +304,22 @@
<table tableName="RegexRename">
<columnRenamingRule searchString="^CUST" />
</table>
+ </ibatorContext>
+
+ <ibatorContext id="miscellaneousTests_NoDAO" targetRuntime="Ibatis2Java5">
+ <property name="autoDelimitKeywords" value="true" />
+
+ <jdbcConnection driverClass="org.hsqldb.jdbcDriver"
+ connectionURL="jdbc:hsqldb:mem:aname"
+ userId="sa" />
+
+ <javaModelGenerator
targetPackage="ibatortest.generated.miscellaneous.model"
targetProject="${generated.source.dir.java5}">
+ <property name="trimStrings" value="true" />
+ </javaModelGenerator>
+
+ <sqlMapGenerator targetPackage="ibatortest.generated.miscellaneous.xml"
+ targetProject="${generated.source.dir.java5}"/>
+
<table tableName="AnotherAwfulTable" />
</ibatorContext>
</ibatorConfiguration>