0

The reason I am getting this error is very odd. I will explain the error is chronological order to make it easier to understand.

Here is my JPA query and it was working perfect until I added po.customer_id to it.

@Query("SELECT NEW com.htd.domain.ShopOrder(po.id, po.po_number, "
            + "po.due_date, po.customer_id, po_part.id,po_part.part_quantity, "
            + "part.id, part.part_number, part.part_description, "
            + "part.plasma_hrs_per_part, part.grind_hrs_per_part, "
            + "part.mill_hrs_per_part, part.brakepress_hrs_per_part) "
            + "FROM Po po "
            + "JOIN po.partList po_part "
            + "JOIN po_part.part part "
            + "where po.id = ?1")
    List<ShopOrder> getShopOrder(Long id);

ShopOrder Constructor

 public ShopOrder(long po_id, String po_number, LocalDate po_due_date, BigInteger customer_id,
                     long po_part_id, int part_quantity, long part_id,
                     String part_number, String part_decription, BigDecimal plasma_hrs,
                     BigDecimal grind_hours, BigDecimal mill_hrs,
                     BigDecimal breakpress_hrs) {

        this.po_id = po_id;
        this.po_number = po_number;
        this.po_due_date = po_due_date;
        this.po_part_id = po_part_id;
        this.part_quantity = part_quantity;
        this.part_id = part_id;
        this.part_number = part_number;
        this.part_decription = part_decription;
        this.plasma_hrs = plasma_hrs;
        this.grind_hours = grind_hours;
        this.mill_hrs = mill_hrs;
        this.breakpress_hrs = breakpress_hrs;
        this.customer_id = customer_id;

    }

Picture of database table T_PO

error:

Caused by: org.hibernate.QueryException: could not resolve property: customer_id of: com.htd.domain.Po
    at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:83)
    at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:77)
    at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1978)
    at org.hibernate.hql.internal.ast.tree.FromElementType.getPropertyType(FromElementType.java:367)
    at org.hibernate.hql.internal.ast.tree.FromElement.getPropertyType(FromElement.java:500)
    at org.hibernate.hql.internal.ast.tree.DotNode.getDataType(DotNode.java:652)
    at org.hibernate.hql.internal.ast.tree.DotNode.prepareLhs(DotNode.java:275)
    at org.hibernate.hql.internal.ast.tree.DotNode.resolve(DotNode.java:219)
    at org.hibernate.hql.internal.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:126)
    at org.hibernate.hql.internal.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:121)
    at org.hibernate.hql.internal.ast.tree.DotNode.resolveSelectExpression(DotNode.java:714)
    at org.hibernate.hql.internal.ast.HqlSqlWalker.resolveSelectExpression(HqlSqlWalker.java:958)
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:2257)
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.constructor(HqlSqlBaseWalker.java:2607)
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:2324)
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectExprList(HqlSqlBaseWalker.java:2194)
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectClause(HqlSqlBaseWalker.java:1476)
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:573)
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:301)
    at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:249)
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:278)
    at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:206)
    ... 54 more

I am rather confused on why a column in the table I am calling is not recognized. I have played with this for a while but it feels like I am chasing my tail.

-------UPDATE-------

 public ShopOrder(long po_id, String po_number, LocalDate po_due_date, long customer_id,
                     long po_part_id, int part_quantity, long part_id,
                     String part_number, String part_decription, BigDecimal plasma_hrs,
                     BigDecimal grind_hours, BigDecimal mill_hrs,
                     BigDecimal breakpress_hrs) {

I noticed my other variables that were BigInt in my tables were Long in my constructor. Therefore I changed customer_id to Long but I still got the same error.

1 Answer 1

1

You don't have a customer_id property in your entity (Po class). You should have something like this:

@Entity
public class Po {
    // ...

    @Basic
    long customer_id;

    // ...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.