Note that there are some explanatory texts on larger screens.

plurals
  1. POQueryDSL Generated classes not able to access second level elements for querying
    primarykey
    data
    text
    <p>I am using QueryDSL with Spring Data JPA in my Java Project and have Generated files using QueryDSL maven plugin to use the QueryDSL Model classes generated by it. This works great when i use it for one level nested objects, however if i try to access the 2nd level access objects it gives a NullPointerException saving the 2nd level model object is not initialized. </p> <p>Would appreciate some help.</p> <p>I am getting a NullPointerException in 3rd line qmachine.vendor is null.</p> <pre><code>QTransaction qtransaction = QTransaction.transaction; QMachine qmachine = qtransaction.machine; BooleanExpression vendorexp = qmachine.vendor.vendor.eq(machineType); </code></pre> <p>My Mapping classes are below: Transaction</p> <pre><code>@Entity @Table(name = "dsdsd") public class Transaction extends AbstractPersistable&lt;Long&gt; { private static final long serialVersionUID = 1L; @ManyToOne @JoinColumn(name = "machine_id") private Machine machine; } </code></pre> <p>And the Machine class is :</p> <pre><code>@Entity @Table(name="machine") public class Machine extends AbstractPersistable&lt;Long&gt; { private static final long serialVersionUID = 1L; @ManyToOne @JoinColumn(name="vendor_id") private Vendor vendor; } </code></pre> <p>and the Vendor class is </p> <pre><code>@Entity @Table(name="vendors") public class Vendor extends AbstractPersistable&lt;Long&gt; { private static final long serialVersionUID = 1L; @Column(name="vendor") @Enumerated(EnumType.STRING) private VendorType vendor; } </code></pre> <p>I have ommitted the getters and setters intentionally.</p>
    singulars
    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