Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:oracle10g
The generated SQL (show_sql=true):select otcoperati0_.OTC_OP_ID_OPERATION_PK as OTC1_84_, otcoperati0_.OTC_OP_ID_STATE as OTC2_84_, otcoperati0_.OTC_OP_DT_OPERATION as OTC3_84_, otcoperati0_.OTC_OP_NR_OPERATION as OTC4_84_, otcoperati0_.OTC_OP_ID_OPERATION_TYPE as OTC5_84_, otcoperati0_.OTC_NM_ID_MECHANISM_FK as OTC6_84_, otcoperati0_.OTC_PT_ID_PART_SELLER_PK as OTC7_84_, otcoperati0_.OTC_OR_QUANTITY_STOCKS as OTC8_84_, otcoperati0_.OTC_OR_DT_SETTLEMENT_CASH as OTC9_84_, otcoperati0_.OTC_OR_PRICE_CASH as OTC10_84_, otcoperati0_.OTC_OR_CD_CURRENCY as OTC11_84_, otcoperati0_.OTC_OR_OBSERVATION as OTC12_84_, otcoperati0_.OTC_PT_ID_PARTICIPANT_BUYER_FK as OTC13_84_, otcoperati0_.OTC_SR_CD_ISIN_CODE as OTC14_84_, otcoperati0_.OTC_SR_ISIN_DESC as OTC15_84_, otcoperati0_.OTC_SR_ISIN_ISSUER_CODE as OTC16_84_, otcoperati0_.OTC_IS_ISIN_ISSUER_NAME as OTC17_84_, otcoperati0_.OTC_TO_MNE_SELL_PART_REF as OTC18_84_, otcoperati0_.OTC_TO_MNE_BUY_PARTICIPANT_REF as OTC19_84_, otcoperati0_.OTC_OP_NR_SETTLEMENT_DAYS as OTC20_84_, otcoperati0_.OTC_TO_IN_CONDITIONS as OTC21_84_, otcoperati0_.OTC_OR_TYPE_TRANSFERENCE as OTC22_84_ from OTC_OPERATION_VIEW otcoperati0_ where otcoperati0_.OTC_OP_NR_OPERATION=?
Debug level Hibernate log excerpt:java.lang.NullPointerException
at com.cavali.dao.mgmt.otcoperations.OtcOperationViewDAOTest.testFindByProperty(OtcOperationViewDAOTest.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html
i am trying to fetch the rows from oracle table view but i am getting the list size correctly but the values r coming as null.for the following method
public List findByProperty(String propertyName, Object value) {
Session session = null;
try {
session = HibernateUtil.currentSession();
String queryString = "from OtcOperationView as model where model."
+ propertyName + "= ?";
Query queryObject = session.createQuery(queryString);
queryObject.setParameter(0, value);
return queryObject.list();//here i am getting the size of the list corrctly but values as null
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
} finally {
// HibernateUtil.closeSession();
}
}
and the junit for the following file
public void testFindByProperty() {
OtcOperationViewDAO obj=new OtcOperationViewDAO();
List li=obj.findByProperty("id.otcOpNrOperation", new Long(2104091));
assertEquals(((HolderNameView)li.get(0)).getId().getHolderId(), new Long(5));
}
mapping file
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="com.cavali.dao.beans.mgmt.otcoperations.OtcOperationView" table="OTC_OPERATION_VIEW">
<composite-id name="id" class="com.cavali.dao.beans.mgmt.otcoperations.OtcOperationViewId">
<key-property name="otcOpIdOperationPk" type="java.lang.Long">
<column name="OTC_OP_ID_OPERATION_PK" precision="10" scale="0" />
</key-property>
<key-property name="otcOpIdState" type="java.lang.Long">
<column name="OTC_OP_ID_STATE" precision="2" scale="0" />
</key-property>
<key-property name="otcOpDtOperation" type="java.util.Date">
<column name="OTC_OP_DT_OPERATION" length="7" />
</key-property>
<key-property name="otcOpNrOperation" type="java.lang.Long">
<column name="OTC_OP_NR_OPERATION" precision="20" scale="0" />
</key-property>
<key-property name="otcOpIdOperationType" type="java.lang.Long">
<column name="OTC_OP_ID_OPERATION_TYPE" precision="2" scale="0" />
</key-property>
<key-property name="otcNmIdMechanismFk" type="java.lang.Long">
<column name="OTC_NM_ID_MECHANISM_FK" precision="1" scale="0" />
</key-property>
<key-property name="otcPtIdPartSellerPk" type="java.lang.Long">
<column name="OTC_PT_ID_PART_SELLER_PK" precision="9" scale="0" />
</key-property>
<key-property name="otcOrQuantityStocks" type="java.lang.Double">
<column name="OTC_OR_QUANTITY_STOCKS" precision="18" scale="4" />
</key-property>
<key-property name="otcOrDtSettlementCash" type="java.util.Date">
<column name="OTC_OR_DT_SETTLEMENT_CASH" length="7" />
</key-property>
<key-property name="otcOrPriceCash" type="java.lang.Double">
<column name="OTC_OR_PRICE_CASH" precision="18" scale="8" />
</key-property>
<key-property name="otcOrCdCurrency" type="java.lang.Long">
<column name="OTC_OR_CD_CURRENCY" precision="5" scale="0" />
</key-property>
<key-property name="otcOrObservation" type="java.lang.String">
<column name="OTC_OR_OBSERVATION" length="50" />
</key-property>
<key-property name="otcPtIdParticipantBuyerFk" type="java.lang.Long">
<column name="OTC_PT_ID_PARTICIPANT_BUYER_FK" precision="9" scale="0" />
</key-property>
<key-property name="otcSrCdIsinCode" type="java.lang.String">
<column name="OTC_SR_CD_ISIN_CODE" length="12" />
</key-property>
<key-property name="otcSrIsinDesc" type="java.lang.String">
<column name="OTC_SR_ISIN_DESC" length="100" />
</key-property>
<key-property name="otcSrIsinIssuerCode" type="java.lang.String">
<column name="OTC_SR_ISIN_ISSUER_CODE" length="8" />
</key-property>
<key-property name="otcIsIsinIssuerName" type="java.lang.String">
<column name="OTC_IS_ISIN_ISSUER_NAME" length="100" />
</key-property>
<key-property name="otcToMneSellPartRef" type="java.lang.String">
<column name="OTC_TO_MNE_SELL_PART_REF" length="10" />
</key-property>
<key-property name="otcToMneBuyParticipantRef" type="java.lang.String">
<column name="OTC_TO_MNE_BUY_PARTICIPANT_REF" length="10" />
</key-property>
<key-property name="otcOpNrSettlementDays" type="java.lang.Long">
<column name="OTC_OP_NR_SETTLEMENT_DAYS" precision="3" scale="0" />
</key-property>
<key-property name="otcToInConditions" type="java.lang.String">
<column name="OTC_TO_IN_CONDITIONS" length="2" />
</key-property>
<key-property name="otcOrTypeTransference" type="java.lang.Long">
<column name="OTC_OR_TYPE_TRANSFERENCE" precision="5" scale="0" />
</key-property>
</composite-id>
</class>
</hibernate-mapping>