Association references unmapped class hibernate - java

The configuration for Affiliate class is:
<class name="AffiliatesDO" table="AFFILIATES">
<id name="affiliateId" column="affiliate_id" type="java.lang.String">
<generator class="assigned" />
</id>
<property name="customerId" column="customer_id" type="int" />
<property name="affiliateType" column="affiliate_type" type="java.lang.String" />
<property name="site" column="site" type="java.lang.String" />
<property name="status" column="status" type="java.lang.String" />
<property name="createdBy" column="created_by" type="java.lang.String" />
<property name="creationDate" column="creation_date" type="java.util.Date" />
<property name="lastUpdatedBy" column="last_updated_by" type="java.lang.String" />
<property name="lastUpdated" column="last_updated" type="java.util.Date" />
<set name="address" lazy="true" inverse="true" order-by="address_id asc">
<key column="address_id"/>
<one-to-many class="AddressDO"/>
</set>
</class>
The Configuration for Address class is
<class name="Address"
table="Address">
<id name="addressId" column="address_id"
type="java.lang.String">
<generator class="assigned" />
</id>
<property name="name" column="name" type="java.lang.String" />
<property name="address1" column="address1" type="java.lang.String" />
<property name="phone" column="phone" type="java.lang.String" />
<property name="landLineNumber" column="land_line_number" type="java.lang.String" />
<property name="faxNumber" column="fax_number" type="java.lang.String" />
</class>
I am getting the below error
org.hibernate.MappingException: Association references unmapped class: com.infibeam.customerservice.dbObjects.AddressDO
at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2370)
at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2652)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1054)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1039)
at org.codehaus.mojo.hibernate3.configuration.AbstractComponentConfiguration.getConfiguration(AbstractComponentConfiguration.java:38)
at org.codehaus.mojo.hibernate3.HibernateExporterMojo.configureExporter(HibernateExporterMojo.java:186)
at org.codehaus.mojo.hibernate3.exporter.Hbm2JavaGeneratorMojo.configureExporter(Hbm2JavaGeneratorMojo.java:69)
Kindly show me the mistakes I have made.. I want to use one to many relation AffiliateDO->AddressDO

It looks like your mapping of the parent class is referring to AddressDO, but the subsequent child mapping is referring to Address (No "DO")... If I had to guess, you should change the second mapping to AddressDO (or visa versa). In any event, looks like a typo to me.

Considering Do as a typo error in Addrees xml, The Address mapping seems incorrect, there must address_id must be many-to-one currently it is generated new one.

Related

getting unknown error in my hibernate mapping file

I have three persistent classes named:shops.class,user.class,vehicle.class and three hibernate mapping file shops.hbm.xml,users.hbm.xml,vehicle.hbm.xml
But i am getting following error in my users and vehicle mappingg file:
The content of element type "class" must match
"(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,fetch-profile*,resultset*,(query|sql-query)*)".
shops.hbm.xml:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jun 7, 2017 2:04:29 PM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="persistent_classes.shops" table="SHOPS">
<id name="id" type="int">
<column name="ID" />
<generator class="increment" />
</id>
<version name="version_id" type="int" unsaved-value="undefined">
<column name="VERSION_ID" />
</version>
<property name="name" type="java.lang.String">
<column name="NAME" />
</property>
<property name="address" type="java.lang.String">
<column name="ADDRESS" />
</property>
<property name="city" type="java.lang.String">
<column name="CITY" />
</property>
<property name="dealername" type="java.lang.String">
<column name="DEALERNAME" />
</property>
<property name="dealerno" type="java.lang.String">
<column name="DEALERNO" />
</property>
<property name="dealeremail" type="java.lang.String">
<column name="DEALEREMAIL" />
</property>
<property name="password" type="java.lang.String">
<column name="PASSWORD" />
</property>
<property name="shops_string" type="java.lang.String">
<column name="SHOPS_STRING" />
</property>
<property name="login" type="boolean">
<column name="LOGIN" />
</property>
<list name="vehicles" inverse="false" table="VEHICLE" lazy="true">
<key>
<column name="store_id" />
</key>
<list-index></list-index>
<one-to-many class="persistent_classes.vehicle" />
</list>
<map name="users" table="SHOPS_MAP" lazy="true">
<key>
<column name="ID" />
</key>
<map-key type="java.lang.Integer"></map-key>
<element type="java.lang.Integer">
<column name="USERS" />
</element>
</map>
</class>
</hibernate-mapping>
vehicle.hbm.xml:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jun 7, 2017 2:04:29 PM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="persistent_classes.vehicle" table="VEHICLE">
<id name="id" type="int">
<column name="ID" />
<generator class="increment" />
</id>
<property name="stock" type="int">
<column name="STOCK" />
</property>
<version name="version_id" type="int" unsaved-value="undefined">
<column name="VERSION_ID" />
</version>
<property name="name" type="java.lang.String">
<column name="NAME" />
</property>
<property name="company" type="java.lang.String">
<column name="COMPANY" />
</property>
<property name="milage" type="java.lang.String">
<column name="MILAGE" />
</property>
<property name="year" type="java.lang.String">
<column name="YEAR" />
</property>
<property name="priceoriginal" type="java.lang.String">
<column name="PRICEORIGINAL" />
</property>
<property name="priceoffer" type="java.lang.String">
<column name="PRICEOFFER" />
</property>
<property name="vehicle_string" type="java.lang.String">
<column name="VEHICLE_STRING" />
</property>
</class>
</hibernate-mapping>
users.hbm.xml:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Jun 7, 2017 2:04:40 PM by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="persistent_classes.users" table="USERS">
<id name="id" type="int">
<column name="ID" />
<generator class="increment" />
</id>
<map name="points" table="user_points" cascade="all">
<key column="user_id" />
<index column="shop_id" type="integer"></index>
<element column="points" type="string"></element>
</map>
<version name="version_id" type="int" unsaved-value="undefined">
<column name="VERSION_ID" />
</version>
<property name="login" type="boolean">
<column name="LOGIN" />
</property>
<property name="name" type="java.lang.String">
<column name="NAME" />
</property>
<property name="password" type="java.lang.String">
<column name="PASSWORD" />
</property>
<property name="email" type="java.lang.String">
<column name="EMAIL" />
</property>
<property name="mobno" type="java.lang.String">
<column name="MOBNO" />
</property>
<property name="address" type="java.lang.String">
<column name="ADDRESS" />
</property>
<property name="users_string" type="java.lang.String">
<column name="USERS_STRING" />
</property>
</class>
</hibernate-mapping>
I know this question is asked many times but all of that were related to not using tag. But i had used this tag in all files but still getting this error in users and vehicle file.
Please Help i am badly stuck with this.
Thanks in advance
version must be defined before property and map
Move it to be right after id definition in the users and vehicle hbm

exception here in hbm.xml

<generator class="increment" />
<id name="id" />
<property name="movie" />
<property name="showtimes" />
<property name="seatno" />
</class>
Exception
ERROR: HHH000196: Error parsing XML (2) : The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,fetch-profile*,resultset*,(query|sql-query)*)".
Exception in thread "main" org.hibernate.InvalidMappingException: Unable to read XML
at org.hibernate.internal.util.xml.MappingReader.legacyReadMappingDocument(MappingReader.java:375)
at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:304)
at org.hibernate.cfg.Configuration.add(Configuration.java:516)
at org.hibernate.cfg.Configuration.add(Configuration.java:512)
at org.hibernate.cfg.Configuration.add(Configuration.java:686)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:769)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2255)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2227)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2207)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2160)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2075)
at test.ClientUsingAssigned.main(ClientUsingAssigned.java:16)
Use <generator> tag inside <Id>
<hibernate-mapping>
<class name="Employee" table="EMPLOYEE">
<meta attribute="class-description">
This class contains the employee detail.
</meta>
<id name="id" type="int" column="id">
<generator class="increment"/>
</id>
<property name="firstName" column="first_name" type="string"/>
<property name="lastName" column="last_name" type="string"/>
<property name="salary" column="salary" type="int"/>
</class>
</hibernate-mapping>

Hibernate : why createQuery() appends package name to the Entity Name?

I am trying to query database from two Different Tables i.e.
query = "select rbt.rbtCode, rbt.maskedName, cmas.catId, cmas.maskedName " +
"from CrbtRbt rbt, CrbtCategoryMaster cmas " +
"where rbt.playable='Y' and rbt.showOnWeb='Y' and rbt.rbtCode!=0 " +
"and rbt.catId=cmas.catId";
but when I pass this query through session.createQuery(query);
It appends package name to the next in coming Entity Name i.e.
select rbt.rbtCode, rbt.maskedName, cmas.catId, cmas.maskedName
from CrbtRbt rbt, com.telemune.toolGeneratedPojos.CrbtCategoryMaster cmas
where rbt.playable='Y' and rbt.showOnWeb='Y' and rbt.rbtCode!=0 and rbt.catId=cmas.catId
and gives the following Exception:
org.hibernate.hql.internal.ast.QuerySyntaxException: CrbtRbt is not mapped [select rbt.rbtCode, rbt.maskedName, cmas.catId, cmas.maskedName from CrbtRbt rbt, com.telemune.toolGeneratedPojos.CrbtCategoryMaster cmas where rbt.playable='Y' and rbt.showOnWeb='Y' and rbt.rbtCode!=0 and rbt.catId=cmas.catId]
at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:180)
at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110)
at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:93)
at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:325)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3252)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3141)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:694)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:550)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:287)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:235)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:248)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:119)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:214)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:192)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1537)
at com.telemune.generator.TestQuery.select(TestQuery.java:114)
at com.telemune.generator.PojoGenerator.main(PojoGenerator.java:191)
But if I query the Entities One By One it shows the desired result successfully.
i.e.
select rbt.rbtCode, rbt.maskedName
from CrbtRbt rbt
where rbt.playable='Y' and rbt.showOnWeb='Y' and rbt.rbtCode!=0;
gives desired result.
Can anyone Explain what I can do?
here is some example code:
Query Code
hql = session.createQuery(query);
hql.setMaxResults( querySchema.getMaxRes() );
list=hql.list();
For information I have done All the Mappings and included all the libraries very carefully no chance of any mistake.
UPDATE
As I said I have done the mappings carefully but someone may have doubts so here is the mapping:
<hibernate-mapping>
<class name="com.telemune.toolGeneratedPojos.CrbtCategoryMaster" schema="SDP" table="CRBT_CATEGORY_MASTER">
<id name="catId" type="java.lang.Integer">
<column name="CAT_ID" precision="4" scale="0" />
<generator class="assigned" />
</id>
<property column="SHOW_IN_SMS" name="showInSms" type="java.lang.String" />
<property column="SHOW_ON_WEB" name="showOnWeb" type="java.lang.String" />
<property column="PLAYABLE" name="playable" type="java.lang.String" />
<property column="STATUS" name="status" type="java.lang.String" />
<property column="IMAGE_PATH" name="imagePath" type="java.lang.String" />
<property column="DESCRIPTION" name="description" type="java.lang.String" />
<property column="MASKED_NAME" name="maskedName" type="java.lang.String" />
<property column="IVR_FILEPATH_1" name="ivrFilepath1" type="java.lang.String" />
<property column="IVR_FILEPATH" name="ivrFilepath" type="java.lang.String" />
<property column="MASKED_NAME_1" name="maskedName1" type="java.lang.String" />
</class></hibernate-mapping>
and for CRBT_RBT:
<hibernate-mapping>
<class name="com.telemune.toolGeneratedPojos.CrbtRbt" schema="SDP" table="CRBT_RBT">
<id name="rbtCode" type="java.lang.Integer">
<column name="RBT_CODE" precision="10" scale="0" />
<generator class="assigned" />
</id>
<property column="PLAYABLE" name="playable" type="java.lang.String" />
<property column="OTHER" name="other" type="java.lang.Integer" />
<property column="IMAGE_PATH" name="imagePath" type="java.lang.String" />
<property column="RBT_ORDER" name="rbtOrder" type="java.lang.Integer" />
<property column="VALIDITY_PERIOD" name="validityPeriod" type="java.lang.Integer" />
<property column="LYRICIST" name="lyricist" type="java.lang.String" />
<property column="APPROVED_BY" name="approvedBy" type="java.lang.String" />
<property column="PREV_CAT_ID" name="prevCatId" type="java.lang.Integer" />
<property column="RELEASE_YEAR" name="releaseYear" type="java.lang.Integer" />
<property column="COMPOSER" name="composer" type="java.lang.String" />
<property column="SHOW_ON_WEB" name="showOnWeb" type="java.lang.String" />
<property column="MASKED_NAME" name="maskedName" type="java.lang.String" />
<property column="CONTENT_PROVIDER_CODE" name="contentProviderCode" type="java.lang.Integer" />
<property column="CREATE_DATE" name="createDate" type="java.sql.Date" />
<property column="IVR_FILEPATH" name="ivrFilepath" type="java.lang.String" />
<property column="CORP_ID" name="corpId" type="java.lang.Integer" />
<property column="SHOW_IN_SMS" name="showInSms" type="java.lang.String" />
<property column="ALBUM_NAME" name="albumName" type="java.lang.String" />
<property column="NOKIA" name="nokia" type="java.lang.Integer" />
<property column="STATUS" name="status" type="java.lang.String" />
<property column="FILE_PATH" name="filePath" type="java.lang.String" />
<property column="REFERENCE_ID" name="referenceId" type="java.lang.Integer" />
<property column="CHARGING_CODE" name="chargingCode" type="java.lang.Integer" />
<property column="RBT_NICK" name="rbtNick" type="java.lang.String" />
<property column="APPROVAL_DATE" name="approvalDate" type="java.sql.Date" />
<property column="CAT_ID" name="catId" type="java.lang.Integer" />
<property column="RBT_SCORE" name="rbtScore" type="java.lang.Integer" />
<property column="ARTIST_NAME" name="artistName" type="java.lang.String" />
</class>
</hibernate-mapping>
I don't think there is any mistake in the mapping.
Hibernate.cfg.xml :
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password">sdp</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:#10.168.2.127:1521:mastera</property>
<property name="hibernate.connection.username">sdp</property>
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
<mapping resource="com/telemune/toolGeneratedPojos/CrbtRbt.hbm.xml"/>
<mapping resource="com/telemune/toolGeneratedPojos/CrbtCategoryMaster.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Well, I got this.
SessionFactory getSessionFactory(className) {
try {
configuration.addResource( className + ".hbm.xml" );
}catch (Exception e) {
e.printStackTrace();
}
configuration.configure();
serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
return configuration.buildSessionFactory(serviceRegistry);
here is the code to add .hbm.xml file,programatically, for each class while creating session factory.
try {
sessionFactory = ...getSessionFactory(className);
session = sessionFactory.openSession();
}
catch (Exception e) {
e.printStackTrace();
}
the problem with this code was that:
1. It was building a new session factory for each call(of getSessionFactory(classname)).
2. a new session was opened every time.
So, only the mapping of last class added to configuration was added as a resource and that's why its was searching the other classes by appending the packageName to it's name.
What I did is:
I just counted the no of mapping files in the package and added them with the help of a loop in the same session factory.
And it worked.
Here is the way:
File file = new File(packageName.replace(".", "/"));
for(File file1 : file.listFiles()){
if(file1.getName().trim().substring(file1.getName().trim().lastIndexOf("."),
file1.getName().trim().length()).equalsIgnoreCase(".xml")){
configuration.addResource( packageName.replaceAll("\\.", "/") + "/" + file1.getName() );
}
}
It was just a silly mistake.

org.hibernate.exception.MappingException or ConstraintViolation

I am using hibernate 4.1.9. I have Users, and the Users have a list of Accounts, and Accounts have list of Transactions. Here is my hbm.xml
<?xml version="1.0"?>
<class name="User" table="users">
<id name="userId" column="userid">
<generator class="increment"/>
</id>
<property name="username" column="username" not-null="true"/>
<property name="password" column="password" not-null="true"/>
<property name="registerDate" type="timestamp" column="register_date"/>
<list name="accounts" table="accounts" inverse="true" cascade="all">
<key column="userid" not-null="true"/>
<index column="accountid"/>
<one-to-many class="com.joe.data.Account"/>
</list>
</class>
<class name="Account" table="accounts">
<id name="accountId" column="accountid">
<generator class="increment"/>
</id>
<property name="balance" type="big_decimal" column="balance"/>
<property name="lastModified" type="timestamp" column="last_modified"/>
<list name="txns" table="transactions" inverse="true" cascade="all">
<key column="accountId" not-null="true"/>
<index column="transactionId"/>
<one-to-many class="com.joe.data.Transaction"/>
</list>
<many-to-one name="userId" class="User" column="userid" not-null="true"
unique="true" cascade="all"/>
<many-to-one name="accountType" class="AccountType" column="account_type"
not-null="true" cascade="all" unique="true" />
</class>
<class name="Transaction" table="transactions">
<id name="transactionId" column="transactionid">
<generator class="increment"/>
</id>
<property name="description" column="description"/>
<property name="amount" type="big_decimal" column="amount"/>
<property name="dateAdded" column="date_added"/>
<property name="reoccuring" type="numeric_boolean" column="reoccuring"/>
<many-to-one name="category" class="Category" column="category"
not-null="true" cascade="all" unique="true" />
</class>
<class name="Category" table="categories">
<id name="categoryId" column="categoryid"/>
<property name="categoryName" column="categoryname" not-null="true"/>
</class>
<class name="AccountType" table="account_types">
<id name="accountType" column="account_type"/>
<property name="accountName" column="name"/>
</class>
If I leave inverse="true" on the list of accounts (in the User) I get the ConstraintViolationException because the userid is not getting put in the insert query. If I take inverse="true" off of the list of accounts, I get org.hibernate.MappingException: Repeated column in mapping for entity: com.joe.data.Account column: accountid (should be mapped with insert="false" update="false")
To clarify lowercase names are database columns names, camel case are class variable names. I know Transaction class isn't working quite right yet, but if I could get the Accounts to insert I could do the same thing to get the Transactions to insert.
Edit: I added the many-to-one on the Account class and now I am getting another exception where hibernate is complaining about missing a getter for userId in com.joe.data.Account
In order to get inverse="true" work, you need to define many-to-one for User in Account and for Account in Transaction class and mappings.

Migrating Hibernate 3.2.5 to 3.6

Currently We are facing a lot of problem in migrating our Application from Hibernate 3.2.5 to 3.6.1.
The first error that We are facing is :
SEVERE: Invalid column name 'btn_name'. Although btn_name is mapped no where. The actual mapping is btnName.
Here is my mapping file
<hibernate-mapping>
<class abstract="true" name="com.sampleproject.client.beansdm.metadata.Component"
table="component_master">
<id column="metadata_id" name="id" type="long">
<generator class="native" />
</id>
<property column="metadata_type" name="type" type="string" />
<property name="createdDateTime" column="created_date" type="date"
update="false"></property>
<property name="version" type="string" column="version_id"></property>
<property name="currentDate" type="date" column="curr_date"></property>
<property name="currentIP" type="string" column="current_ip"></property>
<many-to-one name="currentUser"
class="com.sampleproject.client.beansdm.domain.common.User" cascade="refresh"
column="current_user_id"></many-to-one>
<property name="latestDate" type="date" column="latest_date"></property>
<property name="latestIP" type="string" column="latest_ip"></property>
<many-to-one name="latestUser"
class="com.sampleproject.client.beansdm.domain.common.User" cascade="refresh"
column="latest_user"></many-to-one>
<property name="recordStatus" type="boolean" column="record_status"></property>
<property name="portal" type="string" column="portal"></property>
<many-to-one cascade="refresh,save-update,delete"
class="com.sampleproject.client.beansdm.metadata.Component" column="md_id"
name="metadata" not-null="false" />
<joined-subclass
name="com.sampleproject.client.beansdm.metadata.uicontrols.UIControl"
table="ui_control_master">
<key column="ui_control_id" />
<property column="display_name" name="displayText" />
<property column="help_text" name="helpText" />
<property column="info_text" name="informativeText" />
<property column="rows" name="rows" type="integer" />
<property column="cols" name="cols" type="integer" />
<property column="btnName" name="btnName" type="string" />
<property name="version" type="string" column="version_id"></property>
<property name="currentDate" type="date" column="curr_date"></property>
<property name="currentIP" type="string" column="current_ip"></property>
<many-to-one name="currentUser"
class="com.sampleproject.client.beansdm.domain.common.User" cascade="refresh"
column="current_user_id"></many-to-one>
<property name="latestDate" type="date" column="latest_date"></property>
<property name="latestIP" type="string" column="latest_ip"></property>
<many-to-one name="latestUser"
class="com.sampleproject.client.beansdm.domain.common.User" cascade="refresh"
column="latest_user"></many-to-one>
<property name="recordStatus" type="boolean" column="record_status"></property>
<property name="portal" type="string" column="portal"></property>
<property name="readOnly" type="boolean" column="read_only"/>
<joined-subclass
name="com.sampleproject.client.beansdm.metadata.uicontrols.InputControl"
table="input_control_master" lazy="true">
<key column="input_control_id" />
<property column="default_value" name="defaultValue"
not-null="false" />
<property column="is_fk" name="fk" />
<property column="validatable" name="validatable" />
<property column="violatable" name="violatable" />
<property name="isRequired" column="is_required"></property>
<property name="ruleType"
type="com.sampleproject.facadeimplementation.util1.UserEnumRuleType"
column="rule_type"></property>
<property name="fileType" column="file_type"></property>
<property name="maxFileSize" column="max_file_size" type="integer"></property>
<property name="precision" column="input_precision" type="integer"></property>
<property name="maxLength" column="maxlength" type="integer"></property>
<property name="minLength" column="minlength" type="integer"></property>
<property name="dateFormatType" column="dateformat"
type="com.sampleproject.facadeimplementation.util1.UserEnumDateFormatType"></property>
<property name="specialCharAllow" column="isspecialcharallow"></property>
<property name="specialChars" column="specialchars" type="string"></property>
<property name="dateType"
type="com.sampleproject.facadeimplementation.util1.UserEnumDateType"
column="date_type"></property>
<property name="minDate" column="mindate" type="string"></property>
<property name="maxDate" column="maxdate" type="string"></property>
<property name="inspection" column="inspection" type="boolean"></property>
<property name="values" column="default_values" type="string"></property>
<property name="targetNames" column="target_names" type="string"></property>
<!--
<many-to-one cascade="save-update, delete"
class="com.sampleproject.client.beansdm.metadata.Column"
column="target_column_id" name="targetColumn" />
-->
<property name="targetColumn" column="target_column" type="string"></property>
<property name="templateName" column="template_name" type="string"></property>
<!--
<bag name="targetColumnNames" cascade="save-update"
table="input_possible_columns_map"> <key
column="input_control_id"></key> <element column="column_name"
not-null="true" type="string" /> </bag>
-->
<!--<bag name="possibleValues" cascade="save-update" table="input_possible_values_map">
<key column="input_control_id" />
<many-to-many
class="com.sampleproject.client.beansdm.metadata.uicontrols.PossibleValue"
column="value" />
</bag>
--><property name="seperator" column="seperator" type="string" />
<many-to-one name="refTable" cascade="refresh"
class="com.sampleproject.client.beansdm.metadata.Table" column="ref_table_id" lazy="false">
</many-to-one>
<many-to-one name="targetTable" cascade="refresh"
class="com.sampleproject.client.beansdm.metadata.Table" column="target_table_id" />
<property name="version" type="string" column="version_id"></property>
<property name="currentDate" type="date" column="curr_date"></property>
<property name="currentIP" type="string" column="current_ip"></property>
<many-to-one name="currentUser"
class="com.sampleproject.client.beansdm.domain.common.User" cascade="refresh"
column="current_user_id"></many-to-one>
<property name="latestDate" type="date" column="latest_date"></property>
<property name="latestIP" type="string" column="latest_ip"></property>
<many-to-one name="latestUser"
class="com.sampleproject.client.beansdm.domain.common.User" cascade="refresh"
column="latest_user"></many-to-one>
<property name="recordStatus" type="boolean" column="record_status"></property>
<property name="portal" type="string" column="portal"></property>
<many-to-one name="linkedColumn" cascade="refresh"
class="com.sampleproject.client.beansdm.metadata.Column" column="linked_column_name">
</many-to-one>
<many-to-one name="linkedMasterColumn" cascade="refresh"
class="com.sampleproject.client.beansdm.metadata.Column" column="linked_master_column">
</many-to-one>
<many-to-one name="linkedTable" cascade="refresh"
class="com.sampleproject.client.beansdm.metadata.Table" column="linked_master_id">
</many-to-one>
</joined-subclass>
</joined-subclass>
</class>
</hibernate-mapping>
Focus on com.sampleproject.client.beansdm.metadata.uicontrols.InputControl joined-subclass mapping there is a field named btnName. Its working fine with 3.2.5 version but when i changed it to newer hibernate version it stops responding.
Is there any possible jar conflicts ?
Please help.
Thanking You,
Regards,
The Hibernate Version Comparison guide states when moving from 3.5 to 3.6 that:
However, for users still using hbm.xml
you should be aware that we chose to
use the
org.hibernate.cfg.EJB3NamingStrategy
used in AnnotationConfigration instead
of the older
org.hibernate.cfg.DefaultNamingStrategy
historically used on Configuration.
This may cause naming mismatches; one
known place where this is an issue is
if you rely on the naming strategy to
default the name of a association
(many-to-many and collections of
elements) table. If you find yourself
in this situation, you can tell
Hibernate to use the the legacy
org.hibernate.cfg.DefaultNamingStrategy
by calling
Configuration#setNamingStrategy and
passing it
org.hibernate.cfg.DefaultNamingStrategy#INSTANCE
The NamingStrategy interface defines several methods like String foreignKeyColumnName(String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName)used to determine the names of columns and associations which are implemented by the EJB3NamingStrategy. I suggest you look at the implementation of these methods in the EJB3NamingStrategy class and see how it is transforming property names to column names.
It looks like hibernate is now adding the underscores to what it expects the column name to be in the DB via one these transformations, and is upset when it can't find the resultant column name 'btn_name' in your database.

Categories

Resources