Note that there are some explanatory texts on larger screens.

plurals
  1. POIssues with mapping a view with hibernate
    primarykey
    data
    text
    <p><strong>Updated:</strong></p> <p>I removed the view from MySQL and modified the annotations of the entity (I modified the class name as well). This now works but I still do not see why I was not able to map hibernate to a view.</p> <pre><code>@Entity @SqlResultSetMapping(name = "implicit", entities = @EntityResult(entityClass = vsg.ecotrak.admin.view.domain.CustomerProgramQtyInquiry.class)) @NamedNativeQuery(name = "VCPQuantity.findByCustomerProgram", query = "select (cust.id * 1000000000) + (s.id * 1000000) + (p.id * 1000) as id, " + " cust.client as customer, " + " cust.id as customer_id, " + " cust.status as customer_status, " + " p.name as program_name, " + " p.id as program_id, " + " p.program_type, " + " p.refill_type, " + " p.status as program_status, " + " s.store_name, " + " s.store_number, " + " s.status as store_status, " + " sic.qty_on_hand, " + " ps.re_order_qty, " + " ps.trigger_qty, " + " ps.initial_order_qty, " + " ps.is_overridden " + " from program as p " + " join program_store as ps on ps.program_id = p.id " + " join customer as cust on cust.id = ps.customer_id " + " join store as s on s.id = ps.store_id " + " join store_inv_cnt as sic on sic.store_id = ps.store_id and sic.customer_id = ps.customer_id and sic.program_id = ps.program_id " + " where cust.id = :customerId and p.id = :programId " + " order by cust.client, s.store_name, s.store_number", resultSetMapping = "implicit") </code></pre> <hr> <p>Using Spring 2.5.6 Hibernate (the one shipped with JBoss 5.1)</p> <ul> <li>org.hibernate.annotations : 3.4.0.GA</li> <li>org.hibernate.commons.annotations : 3.1.0.GA</li> <li>org.hibernate.ejb3.persistence : 1.0.2.GA</li> <li>org.hibernate.entity.manager : 3.4.0.GA</li> <li>org.hibernate.validator : 3.1.0.GA</li> <li>org.hibernate : 3.3.1.GA</li> </ul> <p>MySQL 5.1</p> <p>When I look at the log file I notice that I am not seeing the following: Binding entity from annotated class: entry for the entity in question.</p> <p>When I exercise the code I am getting the following exception: org.hibernate.MappingException: Named query not known: VCPQuantity.findByCustomerProgram</p> <p>I don't really see anything wrong with the implementation. Looking for some direction.</p> <p>Here is what I have in place: </p> <p>The Database View:</p> <pre><code>CREATE OR REPLACE VIEW VCPQUANTITY AS select (cust.id * 1000000000) + (s.id * 1000000) + (p.id * 1000) as id, cust.client as customer, cust.id as customer_id, cust.status as customer_status, p.name as program_name, p.id as program_id, p.program_type, p.refill_type, p.status as program_status, s.store_name, s.store_number, s.status as store_status, sic.qty_on_hand, ps.re_order_qty, ps.trigger_qty, ps.initial_order_qty, ps.is_overridden from program as p join program_store as ps on ps.program_id = p.id join customer as cust on cust.id = ps.customer_id join store as s on s.id = ps.store_id join store_inv_cnt as sic on sic.store_id = ps.store_id and sic.customer_id = ps.customer_id and sic.program_id = ps.program_id order by cust.client, s.store_name, s.store_number; </code></pre> <p>The entity:</p> <pre><code>@Entity @Table(name="vcpquantity") @SqlResultSetMapping(name = "implicit", entities = @EntityResult(entityClass = vsg.ecotrak.admin.view.domain.VCPQuantity.class)) @NamedNativeQuery(name = "VCPQuantity.findByCustomerProgram", query = "select * from vcpquantity where customerId = :customerId and programId = :programId", resultSetMapping = "implicit") public class VCPQuantity implements java.io.Serializable { private static final long serialVersionUID = 7676279337195536457L; @Id @Column(name = "ID", nullable = false) private Long id; @Column(name = "customer_id") private Long customerId; @Column(name = "customer") private String customer; @Column(name = "customer_status") private String customerStatus; @Column(name = "program_id") private Long programId; @Column(name = "program_name") private String programName; @Column(name = "program_type") private String programType; @Column(name = "refill_type") private String refillType; @Column(name = "program_status") private String programStatus; @Column(name = "store_name") private String storeName; @Column(name = "store_number") private String storeNumber; @Column(name = "store_status") private String storeStatus; @Column(name = "qty_on_hand") private Long qtyOnHand; @Column(name = "re_order_qty") private Long reOrderQty; @Column(name = "trigger_qty") private Long triggerQty; @Column(name = "initial_order_qty") private Long initialOrderQty; @Column(name = "is_overridden") private boolean overridden; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload