Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've been looking all day for a solution to this problem. I have a solution / work around.</p> <pre><code>@OneToMany(fetch = FetchType.LAZY,cascade = CascadeType.ALL, orphanRemoval=true ) @JoinColumn(name="PROJECT_ID", nullable=true) private Set&lt;Person&gt; personlist = new HashSet&lt;Person&gt;(); </code></pre> <p>I have a similar issue regarding foods and ingredients. </p> <p>A food can exist without being an ingredient in a recipe. An ingredient can't exist without being a food. So we have a one to <strong>zero</strong> or many between ingredient and food:</p> <p>RECIPE 1 ------------- 1..* INGREDIENT 0..* --------- 1 FOOD</p> <p>Please excuse the rubbish representation above. I hope you get the idea.</p> <p>When fetch type below is EAGER, I get the same issue as you. when it's set to lazy, I don't. </p> <pre><code>@NotFound(action = NotFoundAction.IGNORE) @OneToMany(mappedBy = "food", // the VARIABLE NAME of this class in Ingredient targetEntity = Ingredient.class, // The type that we have many of fetch = FetchType.LAZY, cascade = CascadeType.ALL) private Set&lt;Ingredient&gt; ingredients; </code></pre> <p>This isn't really a good solution, just a work around. I think an EAGER fetch should fetch without error even if there's nothing to fetch, then I'd have foods available and if they happen to be ingredients in recipes, then I'd have those ingredients availabel in my object, and through that, the recipes they are in. If they are not ingredients, just foods on their own, I still want the foods - it's just they'll have no ingredients associated no problem... but can't have them if this is the only work around</p> <p>Does anyone have any better solutions to this? If you do you could save my life here :-)</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.
    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