-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Why h2 ignore query condition in parent table in MSSQL?
PostPosted: Fri Feb 20, 2004 3:39 am 
Regular
Regular

Joined: Wed Dec 03, 2003 9:41 pm
Posts: 87
Hibernate version :2.1rc1
mapping documents :
<hibernate-mapping>
<class name="com.dealeasy.ems.monitor.table.DePurchaseOrderModel" table="de_purchase_order">
<id column="id" name="id" type="java.lang.Long">
<generator class="identity"/>
</id>
<property column="PO_NO" length="15" name="poNo" not-null="true" type="java.lang.String"/>
<property column="INVOICE_NO" length="15" name="invoiceNo" type="java.lang.String"/>
<property column="ORDER_DATE" length="23" name="orderDate" type="java.util.Date"/>
<property column="CUSTORMS_DECLARATION_NO" length="80" name="custormsDeclarationNo" type="java.lang.String"/>
</class>
<class name="com.dealeasy.ems.monitor.table.DePurchaseOrderLineModel" table="de_purchase_order_line">
<id column="id" name="id" type="java.lang.Long">
<generator class="identity"/>
</id>
<many-to-one name="purcOrder" class="com.dealeasy.ems.monitor.table.DePurchaseOrderModel" column="PURC_ORDER_ID"/>
<property column="PART_ID" length="15" name="partId" not-null="true" type="java.lang.String"/>
<property column="DESCRIPTION" length="40" name="description" type="java.lang.String"/>
<property column="ORDER_QTY" length="14" name="orderQty" type="java.lang.Double"/>
<property column="UNIT_PRICE" length="15" name="unitPrice" type="java.lang.Double"/>
<property column="TOTAL_SUM" length="18" name="totalSum" type="java.lang.Long"/>
</class>
</hibernate-mapping>

Java code :
Long purchaseOrderID = new Long(3);
DePurchaseOrderLineModel searchModel = new DePurchaseOrderLineModel();
DePurchaseOrderModel orderModel = new DePurchaseOrderModel();
orderModel.setId(purchaseOrderID);
orderModel.setInvoiceNo("fff");
searchModel.setPurcOrder(orderModel);
result = new DePurchaseOrderLineDAO().queryByConditions(searchModel);

Method queryByConditions:
Session session = super.currentSession();
Criteria crit = session.createCriteria(DePurchaseOrderLineModel.class);
crit.add(Example.create(obj));
return crit.list();

database:MSSQL

Hibernate generate select sql is:
Hibernate: select this.id as id1_, this.PURC_ORDER_ID as PURC_ORD2_1_, this.PART_ID as PART_ID1_, this.DESCRIPTION as DESCRIPT4_1_, this.ORDER_QTY as ORDER_QTY1_, this.UNIT_PRICE as UNIT_PRICE1_, this.TOTAL_SUM as TOTAL_SUM1_, depurcha1_.id as id0_, depurcha1_.PO_NO as PO_NO0_, depurcha1_.INVOICE_NO as INVOICE_NO0_, depurcha1_.ORDER_DATE as ORDER_DATE0_, depurcha1_.CUSTORMS_DECLARATION_NO as CUSTORMS5_0_ from de_purchase_order_line this left outer join de_purchase_order depurcha1_ on this.PURC_ORDER_ID=depurcha1_.id where (1=1)

But in oracle, I rember it will generate sql using inner join instead of left out join and new Hibernate ignore my conditions. In this case it ignore InvoiceNo and Id in parent table de_purchase_order.
Do I have any mistake or it is true different between MSSQL and Oracle?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 3:42 am 
Regular
Regular

Joined: Wed Dec 03, 2003 9:41 pm
Posts: 87
I did another test:Add condition column in table de_purchase_order_line(not parent table), it generate correct sql with this condition.
sql generated by hibernate:
select this.id as id1_, this.PURC_ORDER_ID as PURC_ORD2_1_, this.PART_ID as PART_ID1_, this.DESCRIPTION as DESCRIPT4_1_, this.ORDER_QTY as ORDER_QTY1_, this.UNIT_PRICE as UNIT_PRICE1_, this.TOTAL_SUM as TOTAL_SUM1_, depurcha1_.id as id0_, depurcha1_.PO_NO as PO_NO0_, depurcha1_.INVOICE_NO as INVOICE_NO0_, depurcha1_.ORDER_DATE as ORDER_DATE0_, depurcha1_.CUSTORMS_DECLARATION_NO as CUSTORMS5_0_ from de_purchase_order_line this left outer join de_purchase_order depurcha1_ on this.PURC_ORDER_ID=depurcha1_.id where (this.ORDER_QTY=?)

So is it different deal with parent table condition in Example between MSSQL and Oracle?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.