Liquibase Unknown change type 'loadData' - spring-boot

I have been using JHipster for a long time.
But suddenly, I faced this stupid exception, and I couldn't find any solution for it.
I have exactly one other project that works without any problem, but in this project Liquibase says that it does not recognize the loadData change type.
liquibase.parser.core.ParsedNodeException: Error parsing config/liquibase/changelog/00000000000000_initial_schema.xml: Unknown change type 'loadData'. Check for spelling or capitalization errors and missing extensions such as liquibase-commercial.
I would appreciate any help🙏
Full Stacktrace:
2022-10-19T13:19:45.872+02:00 ERROR 182498 --- [all-club-task-1] t.j.c.liquibase.AsyncSpringLiquibase : Liquibase could not start correctly, your database is NOT ready: liquibase.exception.SetupException: liquibase.parser.core.ParsedNodeException: Error parsing config/liquibase/changelog/00000000000000_initial_schema.xml: Unknown change type 'loadData'. Check for spelling or capitalization errors and missing extensions such as liquibase-commercial.
liquibase.exception.ChangeLogParseException: liquibase.exception.SetupException: liquibase.parser.core.ParsedNodeException: Error parsing config/liquibase/changelog/00000000000000_initial_schema.xml: Unknown change type 'loadData'. Check for spelling or capitalization errors and missing extensions such as liquibase-commercial.
at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:25)
at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:380)
at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:365)
at liquibase.Liquibase.lambda$update$1(Liquibase.java:222)
at liquibase.Scope.lambda$child$0(Scope.java:180)
at liquibase.Scope.child(Scope.java:189)
at liquibase.Scope.child(Scope.java:179)
at liquibase.Scope.child(Scope.java:158)
at liquibase.Liquibase.runInScope(Liquibase.java:2414)
at liquibase.Liquibase.update(Liquibase.java:209)
at liquibase.Liquibase.update(Liquibase.java:195)
at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:314)
at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:269)
at org.springframework.boot.autoconfigure.liquibase.DataSourceClosingSpringLiquibase.afterPropertiesSet(DataSourceClosingSpringLiquibase.java:46)
at tech.jhipster.config.liquibase.AsyncSpringLiquibase.initDb(AsyncSpringLiquibase.java:118)
at tech.jhipster.config.liquibase.AsyncSpringLiquibase.lambda$afterPropertiesSet$0(AsyncSpringLiquibase.java:93)
at tech.jhipster.async.ExceptionHandlingAsyncTaskExecutor.lambda$createWrappedRunnable$1(ExceptionHandlingAsyncTaskExecutor.java:79)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: liquibase.exception.SetupException: liquibase.parser.core.ParsedNodeException: Error parsing config/liquibase/changelog/00000000000000_initial_schema.xml: Unknown change type 'loadData'. Check for spelling or capitalization errors and missing extensions such as liquibase-commercial.
at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:391)
at liquibase.changelog.DatabaseChangeLog.load(DatabaseChangeLog.java:339)
at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:23)
... 19 common frames omitted
Caused by: liquibase.exception.ChangeLogParseException: liquibase.parser.core.ParsedNodeException: Error parsing config/liquibase/changelog/00000000000000_initial_schema.xml: Unknown change type 'loadData'. Check for spelling or capitalization errors and missing extensions such as liquibase-commercial.
at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:25)
at liquibase.changelog.DatabaseChangeLog.include(DatabaseChangeLog.java:671)
at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:383)
... 21 common frames omitted
Caused by: liquibase.parser.core.ParsedNodeException: Error parsing config/liquibase/changelog/00000000000000_initial_schema.xml: Unknown change type 'loadData'. Check for spelling or capitalization errors and missing extensions such as liquibase-commercial.
at liquibase.changelog.ChangeSet.toChange(ChangeSet.java:525)
at liquibase.changelog.ChangeSet.handleChildNode(ChangeSet.java:454)
at liquibase.changelog.ChangeSet.load(ChangeSet.java:382)
at liquibase.changelog.DatabaseChangeLog.createChangeSet(DatabaseChangeLog.java:715)
at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:370)
at liquibase.changelog.DatabaseChangeLog.load(DatabaseChangeLog.java:339)
at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:23)
... 23 common frames omitted
My databaseChangeLog file:
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="00000000000000" author="jhipster">
<createSequence sequenceName="sequence_generator" startValue="1050" incrementBy="50"/>
</changeSet>
<!--
JHipster core tables.
The initial schema has the '00000000000001' id, so that it is over-written if we re-generate it.
-->
<changeSet id="00000000000001" author="jhipster">
<createTable tableName="jhi_user">
<column name="id" type="${uuidType}">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="login" type="varchar(50)">
<constraints unique="true" nullable="false" uniqueConstraintName="ux_user_login"/>
</column>
<column name="password_hash" type="varchar(60)"/>
<column name="email" type="varchar(191)">
<constraints unique="true" nullable="true" uniqueConstraintName="ux_user_email"/>
</column>
<column name="image_url" type="varchar(256)"/>
<column name="activated" type="boolean" valueBoolean="false">
<constraints nullable="false" />
</column>
<column name="lang_key" type="varchar(10)"/>
<column name="activation_key" type="varchar(20)"/>
<column name="reset_key" type="varchar(20)"/>
<column name="created_by" type="varchar(50)">
<constraints nullable="false"/>
</column>
<column name="created_date" type="timestamp"/>
<column name="reset_date" type="timestamp">
<constraints nullable="true"/>
</column>
<column name="last_modified_by" type="varchar(50)"/>
<column name="last_modified_date" type="timestamp"/>
</createTable>
<createTable tableName="jhi_authority">
<column name="name" type="varchar(50)">
<constraints primaryKey="true" nullable="false"/>
</column>
</createTable>
<createTable tableName="jhi_user_authority">
<column name="user_id" type="${uuidType}">
<constraints nullable="false"/>
</column>
<column name="authority_name" type="varchar(50)">
<constraints nullable="false"/>
</column>
</createTable>
<addPrimaryKey columnNames="user_id, authority_name" tableName="jhi_user_authority"/>
<addForeignKeyConstraint baseColumnNames="authority_name"
baseTableName="jhi_user_authority"
constraintName="fk_authority_name"
referencedColumnNames="name"
referencedTableName="jhi_authority"/>
<addForeignKeyConstraint baseColumnNames="user_id"
baseTableName="jhi_user_authority"
constraintName="fk_user_id"
referencedColumnNames="id"
referencedTableName="jhi_user"/>
<addNotNullConstraint columnName="password_hash"
columnDataType="varchar(60)"
tableName="jhi_user"/>
<loadData
file="config/liquibase/data/user.csv"
separator=";"
tableName="jhi_user"
usePreparedStatements="true">
<column name="id" type="${uuidType}"/>
<column name="activated" type="boolean"/>
<column name="created_date" type="timestamp"/>
</loadData>
<dropDefaultValue tableName="jhi_user" columnName="created_date" columnDataType="${datetimeType}"/>
<loadData
file="config/liquibase/data/authority.csv"
separator=";"
tableName="jhi_authority"
usePreparedStatements="true">
<column name="name" type="string"/>
</loadData>
<loadData
file="config/liquibase/data/user_authority.csv"
separator=";"
tableName="jhi_user_authority"
usePreparedStatements="true">
<column name="user_id" type="${uuidType}"/>
</loadData>
</changeSet>
<changeSet author="jhipster" id="00000000000002" context="test">
<createTable tableName="jhi_date_time_wrapper">
<column name="id" type="BIGINT">
<constraints primaryKey="true" primaryKeyName="jhi_date_time_wrapperPK"/>
</column>
<column name="instant" type="timestamp"/>
<column name="local_date_time" type="timestamp"/>
<column name="offset_date_time" type="timestamp"/>
<column name="zoned_date_time" type="timestamp"/>
<column name="local_time" type="time"/>
<column name="offset_time" type="time"/>
<column name="local_date" type="date"/>
</createTable>
</changeSet>
</databaseChangeLog>

I spoke with #nvoxland about this yesterday, and he said that he answered a very similar question on the Liquibase forum.
The short version: you need to update to the most current Liquibase release and then try again. If that doesn't work, then you should add open.csv to the dependency.

Related

How to get db information using Spring JdbcTemplate and plain SQL (Micronaut)

I am trying to create a web application using Micronaut and need to get information from travelLog table using Spring JdbcTemplate and plain
SQL. I was using this tutorial https://www.greggbolinger.com/posts/using-springs-jdbctemplate-with-micronaut/ to solve this, but I faced the following problem:
30.869 [default-nioEventLoopGroup-1-2] ERROR i.m.h.s.netty.RoutingInBoundHandler - Unexpected error occurred: StatementCallback; bad SQL grammar [SELECT * FROM travelLog]; nested exception is org.postgresql.util.PSQLException: ERROR: relation "travellog" does not exist
Position: 15
org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [SELECT * FROM travelLog]; nested exception is org.postgresql.util.PSQLException: ERROR: relation "travellog" does not exist
Position: 15
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:237)
at
Here is travelLog table Schema
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<changeSet id="01" author="julia">
<createTable tableName="travelLog"
remarks="A table to contain all travel logs">
<column name="id" type="int">
<constraints nullable="false" unique="true" primaryKey="true"/>
</column>
<column name="date" type="timestamp">
<constraints nullable="false"/>
</column>
<column name="regNumber" type="varchar">
<constraints nullable="false"/>
</column>
<column name="ownersName" type="varchar(50)">
<constraints nullable="false"/>
</column>
<column name="odometerValueBeg" type="int">
<constraints nullable="false"/>
</column>
<column name="odometerValueEnd" type="int">
<constraints nullable="false"/>
</column>
<column name="departurePlace" type="varchar(255)">
<constraints nullable="false"/>
</column>
<column name="destinationPlace" type="varchar(255)">
<constraints nullable="false"/>
</column>
<column name="description" type="varchar">
</column>
</createTable>
</changeSet>
</databaseChangeLog>
Here is JdbcTemplateFactory.java
#Factory
public class JdbcTemplateFactory {
#Inject
DataSource dataSource;
#Bean
#Singleton
JdbcTemplate jdbcTemplate() {
return new JdbcTemplate(dataSource);
}
}
Here is TravelLogService.java
#Singleton
#Requires(beans = JdbcTemplate.class)
public class TravelLogService {
private final JdbcTemplate jdbcTemplate;
public TravelLogService(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
#Transactional
public void printUsernames() {
jdbcTemplate.query("SELECT * FROM travelLog", (rs) -> {
System.out.println(rs.getString("ownersName"));
});
}
To create and query case sensitive table, columns etc, names must be quoted like this:
SELECT * FROM "travelLog"
For liquibase settings check this answer https://stackoverflow.com/a/60654633/1854103
Also please consider change your naming conventions

Propel2 Reverse second run has deleted columns

I am new to propel. There doesn't appear to be a version command built in, but composer shows propel2 in my description.
I reverse engineered my scheme and models from the database then took six months off the project, came back, remastered the database directly, deleted the generated-classes, and the generated-reversed-database.
I then ran
propel reverse "mysql:host=localhost;dbname=MyVanLog;user=**;password=**"
When that completed I opened my schema.xml file and visually verified that the fuel price column no longer exists.
<table name="LogEntries" idMethod="native" phpName="Logentries">
<column name="LogEntryId" phpName="Logentryid" type="INTEGER" primaryKey="true" autoIncrement="true" required="true"/>
<column name="UserId" phpName="Userid" type="INTEGER" primaryKey="true" required="true"/>
<column name="RvId" phpName="Rvid" type="INTEGER" primaryKey="true" required="true"/>
<column name="Title" phpName="Title" type="VARCHAR" size="45" required="true"/>
<column name="Description" phpName="Description" type="CLOB"/>
<column name="Longitude" phpName="Longitude" type="DECIMAL" size="10" scale="8"/>
<column name="Latitude" phpName="Latitude" type="DECIMAL" size="10" scale="8"/>
<column name="Temperature" phpName="Temperature" type="DECIMAL" size="3" scale="1"/>
<column name="Private" phpName="Private" type="VARCHAR" size="1" sqlType="bit(1)" required="true"/>
<column name="CreatedOnUTC" phpName="Createdonutc" type="TIMESTAMP" required="true"/>
<column name="ModifiedOnUTC" phpName="Modifiedonutc" type="TIMESTAMP" required="true"/>
<foreign-key foreignTable="Users" name="FK_36">
<reference local="UserId" foreign="UserId"/>
</foreign-key>
<foreign-key foreignTable="Rvs" name="FK_40">
<reference local="RvId" foreign="RvId"/>
<reference local="UserId" foreign="UserId"/>
</foreign-key>
<index name="fkIdx_36">
<index-column name="UserId"/>
</index>
<index name="fkIdx_40">
<index-column name="RvId"/>
<index-column name="UserId"/>
</index>
<vendor type="mysql">
<parameter name="Engine" value="InnoDB"/>
</vendor>
Then I run propel build to generate my models. I open my base/LogEntries file and it has all the methods to manipulate the field that is no longer there. I won't paste the entire file, but here is the get method.
/**
* Get the [fuelpriceinvalid] column value.
*
* #return string
*/
public function getFuelpriceinvalid()
{
return $this->fuelpriceinvalid;
}
Does anyone know what I missed?
I had an extra schema.xml file hanging out in the project directories that was being read instead of the one I generated causing the old fields to generate. This was likely just a mistake on my part, not a propel bug.

spring-boot with liquibase #OneToMany mapping

I have two entity Person and Address. And Person can have multiple Address.
<createTable tableName="ADDRESS">
<column name="id" type="bigint(20)" autoIncrement="true">
<constraints primaryKey="true" nullable="false" />
... //columns
</column>
</createTable>
<createTable tableName="PERSON">
<column name="id" type="bigint(20)" autoIncrement="true">
<constraints primaryKey="true" nullable="false" />
... //columns
</column>
</createTable>
<addForeignKeyConstraint
constraintName="fk_constraint_worker_phone_number"
referencedTableName="CONTACT_NUMBER" baseColumnNames="ContactNumbers"
baseTableName="WORKER" referencedColumnNames="id" />
I want 3rd table (like hibernate generate in #OneToMany mapping).
How to do this with liquibase-springboot?
If the relation is truly a OnToMany, you don't need a 3rd table. Simply, add PrimaryKeyJoinColumn.
If the address can be reused for many persons, it's a ManyToMany relation.
You can use #ManytoMany and add information about you joined table un #jointable
Well, in case of liquibase we have to create the 3rd table manually and have to apply the necessary constraints.
Create the table which manages the mapping :
<createTable tableName="PERSON_ADDRESS">
<column name="PERSON_ID" type="BIGINT">
<constraints primaryKey="true" nullable="false" />
</column>
<column name="ADDRESS_ID" type="BIGINT">
<constraints primaryKey="true" nullable="false" />
</column>
</createTable>
Apply the constraints:
1) Ensure that Persons id is unique in the mapping table
2) A foreign key relationship between ADDRESS's id and PERSON_ADDRESS's PERSON_ID
3) A foreign key relationship between PERSON's id and PERSON_ADDRESS's ADDRESS_ID
<addUniqueConstraint
columnNames="PERSON_ID" tableName="PERSON_ADDRESS"
constraintName="UK_PHONE_NUMBERS_ID" />
<addForeignKeyConstraint
constraintName="FK_ADDRESS_PERSON_ADDRESS"
referencedTableName="ADDRESS"
baseColumnNames="ADDRESS_ID"
baseTableName="PERSON_ADDRESS" referencedColumnNames="id" />
<addForeignKeyConstraint
constraintName="FK_PERSON_PERSON_ADDRESS"
referencedTableName="PERSON"
baseColumnNames="PERSON_ID"
baseTableName="PERSON_ADDRESS" referencedColumnNames="id" />

hibernate template find() HibernateObjectRetrievalFailureException

We have some legacy code that works in one environment and not another. The offending block is:
String hql = "from UsrOrgLvlAsgnT where usrAccountT.usrId = ? ";
List<UsrOrgLvlAsgnT> result= getHibernateTemplate().find(hql,usrId);
return result;
the log seems to indicate two SQL calls being run, getting the main record (UsrOrgLvlAsgnT) runs first and I presume succeeds, but then a second call to get a detail record runs, and seems to issue the error.
Problem 1 - This should not be eager fetching. HBM follows:
<hibernate-mapping>
<class name="gov.usdoj.afms.umc.hibernate.model.UsrOrgLvlAsgnT" table="USR_ORG_LVL_ASGN_T" schema="UMC" dynamic-update="true">
<id name="usrAsgnId" type="int">
<column name="USR_ASGN_ID" />
<generator class="identity" />
</id>
<many-to-one name="usrAccountT" class="gov.usdoj.afms.umc.hibernate.model.UsrAccountT" fetch="select" cascade="save-update">
<column name="USR_ID" length="60" not-null="true" />
</many-to-one>
<many-to-one name="structureL" class="gov.usdoj.afms.umc.hibernate.model.StructureL" update="true" insert="true" fetch="select" cascade="save-update">
<column name="STRUCTURE_CD" length="2" not-null="true" />
</many-to-one>
<many-to-one name="orgLvl1L" class="gov.usdoj.afms.umc.hibernate.model.OrgLvl1L" update="false" insert="false" fetch="select" not-found="ignore" not-null="false" cascade="save-update">
<column name="STRUCTURE_CD" length="2" not-null="true" />
<column name="ORG_LVL1_CD" length="5" />
</many-to-one>
<many-to-one name="orgLvl2L" class="gov.usdoj.afms.umc.hibernate.model.OrgLvl2L" update="false" insert="false" fetch="select" not-found="ignore" not-null="false" cascade="save-update">
<column name="STRUCTURE_CD" length="2" not-null="true" />
<column name="ORG_LVL1_CD" length="5" />
<column name="ORG_LVL2_CD" length="6" />
</many-to-one>
<many-to-one name="orgLvl3L" class="gov.usdoj.afms.umc.hibernate.model.OrgLvl3L" update="false" insert="false" fetch="select" not-found="ignore" not-null="false" cascade="save-update">
<column name="STRUCTURE_CD" length="2" not-null="true" />
<column name="ORG_LVL1_CD" length="5" />
<column name="ORG_LVL2_CD" length="6" />
<column name="ORG_LVL3_CD" length="12" />
</many-to-one>
<many-to-one name="orgLvl4L" class="gov.usdoj.afms.umc.hibernate.model.OrgLvl4L" update="false" insert="false" fetch="select" not-found="ignore" not-null="false" cascade="save-update">
<column name="STRUCTURE_CD" length="2" not-null="true" />
<column name="ORG_LVL1_CD" length="5" />
<column name="ORG_LVL2_CD" length="6" />
<column name="ORG_LVL3_CD" length="12" />
<column name="ORG_LVL4_CD" length="6" />
</many-to-one>
<property name="updtTmstmp" type="timestamp" generated="always">
<column name="UPDT_TMSTMP" length="26" not-null="true" />
</property>
<property name="dfltOrgLvl" type="java.lang.Character">
<column name="DFLT_ORG_LVL" length="1" />
</property>
</class>
</hibernate-mapping>
Problem 2 - This FK relationship is a legacy deal and the folks before us used blanks for nulls. I have no idea why. But I can't realistically change it at this time. Is there a way to make hibernate handle this empty relationship without blowing up?
The Exception:
[10/15/13 10:17:12:897 EDT] 0000002e SystemOut O ERROR [WebContainer : 7] (St60Servlet.java:82) - Error in St60. Process will not continue:
java.lang.RuntimeException: org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException: No row with the given identifier exists: [gov.usdoj.afms.umc.hibernate.model.OrgLvl2L#gov.usdoj.afms.umc.hibernate.model.OrgLvl2LId#3d4ed6f3]; nested exception is org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [gov.usdoj.afms.umc.hibernate.model.OrgLvl2L#gov.usdoj.afms.umc.hibernate.model.OrgLvl2LId#3d4ed6f3]
at gov.usdoj.afms.umc.services.St60Service.fetchOU(St60Service.java:373)
at gov.usdoj.afms.umc.services.St60Service.buildOU(St60Service.java:325)
at gov.usdoj.afms.umc.services.St60Service.verifyUserGroups(St60Service.java:178)
at gov.usdoj.afms.umc.services.St60Service.verifyUpdate(St60Service.java:64)
at gov.usdoj.afms.umc.services.St60Service$$FastClassByCGLIB$$7efbe043.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:692)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:108)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:108)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:625)
at gov.usdoj.afms.umc.services.St60Service$$EnhancerByCGLIB$$d08c239.verifyUpdate(<generated>)
at gov.usdoj.afms.umc.St60.St60Servlet.doGet(St60Servlet.java:73)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1536)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1470)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:131)
at gov.usdoj.afms.umc.utils.hibernate.DBParameterFilter.doFilter(DBParameterFilter.java:46)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:363)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:77)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:858)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:824)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:458)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:175)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3742)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:929)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:178)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture$1.run(AsyncChannelFuture.java:205)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)
Caused by:
org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException: No row with the given identifier exists: [gov.usdoj.afms.umc.hibernate.model.OrgLvl2L#gov.usdoj.afms.umc.hibernate.model.OrgLvl2LId#3d4ed6f3]; nested exception is org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [gov.usdoj.afms.umc.hibernate.model.OrgLvl2L#gov.usdoj.afms.umc.hibernate.model.OrgLvl2LId#3d4ed6f3]
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:663)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:912)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:908)
at gov.usdoj.afms.umc.hibernate.dao.HibernateAccountInfoDaoImpl.fetchUsrOrgLvlAsgnById(HibernateAccountInfoDaoImpl.java:144)
at sun.reflect.GeneratedMethodAccessor914.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:599)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196)
at $Proxy70.fetchUsrOrgLvlAsgnById(Unknown Source)
at gov.usdoj.afms.umc.services.St60Service.fetchOU(St60Service.java:360)
... 50 more
Caused by:
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [gov.usdoj.afms.umc.hibernate.model.OrgLvl2L#gov.usdoj.afms.umc.hibernate.model.OrgLvl2LId#3d4ed6f3]
at org.hibernate.impl.SessionFactoryImpl$2.handleEntityNotFound(SessionFactoryImpl.java:447)
at org.hibernate.event.def.DefaultLoadEventListener.returnNarrowedProxy(DefaultLoadEventListener.java:320)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:277)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1080)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1028)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:623)
at org.hibernate.type.EntityType.resolve(EntityType.java:431)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:140)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:898)
at org.hibernate.loader.Loader.doQuery(Loader.java:773)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270)
at org.hibernate.loader.Loader.doList(Loader.java:2294)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2172)
at org.hibernate.loader.Loader.list(Loader.java:2167)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:448)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1258)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:921)
at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:1)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
... 61 more

Error 500: could not initialize a collection in hibernate mapping

I am a newbie for Hibernate. Hope you guys can help me debug below error which really make me crazy.
I got a table called CONTENT_WORKGROUP which will map to another table called CONTENT_WORKGROUP_ROLE. Below is the table structure and sample data:
CONTENT_WORKGROUP
CM_WORKGROUP_ID NUMBER(15,0)
WORKGROUP_ID NUMBER(15,0)
ROLE_ID VARCHAR2(20 BYTE)
CONTENT_WORKGROUP_ROLE
CM_WORKGROUP_ROLE_ID NUMBER(15,0)
ROLE_ID VARCHAR2(20 BYTE)
FUNCTION_ID VARCHAR2(40 BYTE)
P/S: One user workgroup can have multiple role (Creator, Admin, Approver). The function(Add, Edit, Delete) that can perform by this workgroup can be query from CONTENT_WORKGROUP_ROLE.
Sample DATA:
CONTENT_WORKGROUP
CM_WORKGROUP_ID WORKGROUP_ID ROLE_ID
1 136 Creator
2 137 Administrator
3 136 Administrator
CONTENT_WORKGROUP_ROLE
CM_WORKGROUP_ROLE_ID ROLE_ID FUNCTION_ID
1 Creator Copy
2 Creator Edit
3 Creator Delete
4 Creator Add
5 Administrator Edit
6 Administrator Approve
7 Administrator Reject
However, I am getting the error when I get the SET of ContentWorkgroupRole hold by particular workgroup.
[11/23/10 15:28:56:053 SGT] 00000039 SystemOut O [23/11/2010 15:28:56.053] ERROR JDBCExceptionReporter - ORA-01722: invalid number
[11/23/10 15:28:56:100 SGT] 00000039 ServletWrappe E SRVE0068E: Uncaught exception thrown in one of the service methods of the servlet: action. Exception thrown : javax.servlet.ServletException: could not initialize a collection: [corp.celcom.next.infochannel.model.ContentWorkgroup.contentWorkgroupRole#1]
Below is my hibernate mapping file:
ContentWorkgroup.hbm.xml
<hibernate-mapping>
<class name="corp.celcom.next.infochannel.model.ContentWorkgroup" table="CM_WORKGROUP" >
<id name="cmWorkgroupId" type="long">
<column name="CM_WORKGROUP_ID" precision="15" scale="0" />
CM_WORKGROUP
CM_WORKGROUP_ID
ContentWorkgroupRole.hbm.xml
<hibernate-mapping>
<class name="corp.celcom.next.infochannel.model.ContentWorkgroupRole" table="CM_WORKGROUP_ROLE" >
<id name="cmWorkgroupRoleId" type="long">
CM_WORKGROUP_ROLE_ID
CM_WORKGROUP_ROLE
<many-to-one name="contentWorkgroup" class="corp.celcom.next.infochannel.model.ContentWorkgroup" fetch="select">
<column name="ROLE_ID" precision="15" scale="0" />
</many-to-one>
In my ACTION class, the above mentioned error occured on this line:
Iterator iter = cw.getContentWorkgroupRole().iterator();
for(ContentWorkgroup cw : contentWorkgroupList)
{
Iterator iter = cw.getContentWorkgroupRole().iterator();
while (iter.hasNext()) {
ContentWorkgroupRole role = (ContentWorkgroupRole) iter.next();
if (role.getFunctionId().equalsIgnoreCase(Constant.ADD))
myForm.setAllowAdd(true);
if (role.getFunctionId().equalsIgnoreCase(Constant.EDIT))
myForm.setAllowEdit(true);
if (role.getFunctionId().equalsIgnoreCase(Constant.DELETE))
myForm.setAllowDelete(true);
}
}
The weird part is when I change the ROLE_ID to Integer/Long (i.e 1-Creator, 2-Administrator), instead of using String, it work fine! I couldn't understand why and what the problem on my code.
Thanks for you help. It took me 1 day already to cope with this error. Thanks!
Sorry, the display seem got abit problem. I write again here:
ContentWorkgroup.hbm.xml
<hibernate-mapping>
<class name="corp.celcom.next.infochannel.model.ContentWorkgroup" table="CM_WORKGROUP" >
<id name="cmWorkgroupId" type="long">
<column name="CM_WORKGROUP_ID" precision="15" scale="0" />
<generator class="corp.celcom.next.util.MultipleTableGenerator" >
<param name="KEYTABLE_VALUE">CM_WORKGROUP</param>
<param name="KEYCOLUMN_VALUE">CM_WORKGROUP_ID</param>
</generator>
</id>
<property name="workgroupId" type="long">
<column name="WORKGROUP_ID" precision="15" scale="0" not-null="true" />
</property>
<property name="srId" type="string">
<column name="SR_ID" length="15" not-null="true" />
</property>
<property name="contentCategoryId" type="string">
<column name="CONTENT_CATEGORY_ID" length="40" not-null="true" />
</property>
<property name="roleId" type="string">
<column name="ROLE_ID" length="20" not-null="true" />
</property>
<set name="contentWorkgroupRole" table="CM_WORKGROUP_ROLE" inverse="true">
<key>
<column name="ROLE_ID" length="20" not-null="true" />
</key>
<one-to-many class="corp.celcom.next.infochannel.model.ContentWorkgroupRole" />
</set>
</class>
ContentWorkgroupRole.hbm.xml
<hibernate-mapping>
<class name="corp.celcom.next.infochannel.model.ContentWorkgroupRole" table="CM_WORKGROUP_ROLE" >
<id name="cmWorkgroupRoleId" type="long">
<column name="CM_WORKGROUP_ROLE_ID" precision="15" scale="0" />
<generator class="corp.celcom.next.util.MultipleTableGenerator">
<param name="KEYCOLUMN_VALUE">CM_WORKGROUP_ROLE_ID</param>
<param name="KEYTABLE_VALUE">CM_WORKGROUP_ROLE</param>
</generator>
</id>
<many-to-one name="contentWorkgroup" class="corp.celcom.next.infochannel.model.ContentWorkgroup" fetch="select">
<column name="ROLE_ID" precision="15" scale="0" />
</many-to-one>
<property name="menuId" type="string">
<column name="MENU_ID" length="40" not-null="true" />
</property>
<property name="functionId" type="string">
<column name="FUNCTION_ID" length="40" not-null="true" />
</property>
In my ACTION class, the above mentioned error occured on this line:
Iterator iter = cw.getContentWorkgroupRole().iterator();
for(ContentWorkgroup cw : contentWorkgroupList)
{
Iterator iter = cw.getContentWorkgroupRole().iterator();
while (iter.hasNext()) {
ContentWorkgroupRole role = (ContentWorkgroupRole) iter.next();
if (role.getFunctionId().equalsIgnoreCase(Constant.ADD))
myForm.setAllowAdd(true);
if (role.getFunctionId().equalsIgnoreCase(Constant.EDIT))
myForm.setAllowEdit(true);
if (role.getFunctionId().equalsIgnoreCase(Constant.DELETE))
myForm.setAllowDelete(true);
}
}

Resources