Note that there are some explanatory texts on larger screens.

plurals
  1. POJPA Named query using object properties
    primarykey
    data
    text
    <p>I am trying to figure out how to create a (named?) query that will join my entities together. Can I use object properties for the new entity and still do this? I can't seem to decipher how that will/should look.</p> <p>I have 2 tables, an order and order_assoc table. For ever re-order created in the order table an entry will be created in order_assoc. Also, a re-order can be based on a previous order. So, I have a column in order_assoc that tells me the order which it was based on.</p> <p>For example, a re-order 4 is created which was based on a previous 1. So, now the assoc table will look like.</p> <pre><code> order order_assoc ------ ------------- 1 new 1 &lt;-pk 4 1 2 new 3 new 4 reorder </code></pre> <p>I have an existing entity class for order. I added a reference (new entity) to the assoc table</p> <pre><code> @OneToOne(fetch = FetchType.LAZY, optional = true, cascade = {CascadeType.ALL}, mappedBy = "onlineAdoptionEntity", targetEntity = OnlineAdoptionReOrderAssocEntity.class) private OnlineAdoptionReOrderAssocEntity reOrderAssocEntity; </code></pre> <p>The new entity looks like this.</p> <pre><code> @Id @Column(name = "OA_REORDER_ID") @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "reOrderNumberSeq") @SequenceGenerator(name = "reOrderNumberSeq", sequenceName = "REORDER_NUMBER_SEQ", allocationSize=1) private Long id; @OneToOne(optional = true,cascade = CascadeType.ALL) @JoinColumn(name="OA_ADOPTION_ID") private OnlineAdoptionEntity onlineAdoptionEntity; @ManyToOne(optional = true) @JoinColumn(name="OA_ORIGINAL_ADOPTION_ID_ASSOC") private OnlineAdoptionEntity baseReOrderAdoption; </code></pre> <p>Any help would be great thanks very much. I saw there was a similar post <a href="https://stackoverflow.com/questions/10158255/named-query-when-property-is-an-object">here</a> - it is just not clear to me after reading this post.</p>
    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.
 

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