Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type:












-1















Below is my Plain POJO object which is having all the mappings. Note that it is not an Entity object.



import javax.persistence.ColumnResult;
import javax.persistence.ConstructorResult;
import javax.persistence.NamedNativeQuery;
import javax.persistence.SqlResultSetMapping;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
@AllArgsConstructor
@SqlResultSetMapping(name = "refundReportMapping", classes = { @ConstructorResult(targetClass = RefundReport.class, columns = {
@ColumnResult(name = "customer_name"),
@ColumnResult(name = "hashed_email"), @ColumnResult(name = "address"),
@ColumnResult(name = "partner_order"),
@ColumnResult(name = "refund_amount") }) })
@NamedNativeQuery(name = "findRefundReportByStatusNamesParamsNative", query = "SELECT concat(bd.first_name,' ',bd.last_name) as 'customer_name',bd.email_address AS 'hashed_email',concat(bd.address1,' ',bd.address2) AS 'address',"
+ o.reservation_id AS 'partner_order',"
+ "(oa.principal_amount+oa.shipping_amount+oa.tax_amount) AS 'refund_amount'"
+ "FROM orders o, order_adjustments oa WHERE oa.status = :status"
+ "and o.buyer_detail_id=bd.buyer_detail_id and o.reservation_id=oa.order_id", resultClass = RefundReport.class, resultSetMapping = "refundReportMapping")
public class RefundReport {

private String customerName, email, address,
partnerOrder;
private BigDecimal partilaRefundAount;

}




public interface RefundReportRepository extends
Repository<RefundReport, String> {

List<RefundReport> findRefundReportByStatus(
@Param("status") String status);

}









share|improve this question

























  • The SqlResultSetMapping and NamedNativeQuery annotations need to be on an Entity, not on the non-entity POJO. stackoverflow.com/a/49536120/1116320

    – HaseebR7
    Nov 13 '18 at 16:15











  • I tried even that as well by providing the Entity, but it is expecting Identifier. My pojo dont have any Id column.

    – sbhargavs
    Nov 14 '18 at 5:06











  • I tried even that as well by providing the Entity, but it is expecting Identifier. My pojo don't have any Id column. So my question is can we define an Identifier in Entity without having ID id column in table.

    – sbhargavs
    Nov 14 '18 at 5:28
















-1















Below is my Plain POJO object which is having all the mappings. Note that it is not an Entity object.



import javax.persistence.ColumnResult;
import javax.persistence.ConstructorResult;
import javax.persistence.NamedNativeQuery;
import javax.persistence.SqlResultSetMapping;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
@AllArgsConstructor
@SqlResultSetMapping(name = "refundReportMapping", classes = { @ConstructorResult(targetClass = RefundReport.class, columns = {
@ColumnResult(name = "customer_name"),
@ColumnResult(name = "hashed_email"), @ColumnResult(name = "address"),
@ColumnResult(name = "partner_order"),
@ColumnResult(name = "refund_amount") }) })
@NamedNativeQuery(name = "findRefundReportByStatusNamesParamsNative", query = "SELECT concat(bd.first_name,' ',bd.last_name) as 'customer_name',bd.email_address AS 'hashed_email',concat(bd.address1,' ',bd.address2) AS 'address',"
+ o.reservation_id AS 'partner_order',"
+ "(oa.principal_amount+oa.shipping_amount+oa.tax_amount) AS 'refund_amount'"
+ "FROM orders o, order_adjustments oa WHERE oa.status = :status"
+ "and o.buyer_detail_id=bd.buyer_detail_id and o.reservation_id=oa.order_id", resultClass = RefundReport.class, resultSetMapping = "refundReportMapping")
public class RefundReport {

private String customerName, email, address,
partnerOrder;
private BigDecimal partilaRefundAount;

}




public interface RefundReportRepository extends
Repository<RefundReport, String> {

List<RefundReport> findRefundReportByStatus(
@Param("status") String status);

}









share|improve this question

























  • The SqlResultSetMapping and NamedNativeQuery annotations need to be on an Entity, not on the non-entity POJO. stackoverflow.com/a/49536120/1116320

    – HaseebR7
    Nov 13 '18 at 16:15











  • I tried even that as well by providing the Entity, but it is expecting Identifier. My pojo dont have any Id column.

    – sbhargavs
    Nov 14 '18 at 5:06











  • I tried even that as well by providing the Entity, but it is expecting Identifier. My pojo don't have any Id column. So my question is can we define an Identifier in Entity without having ID id column in table.

    – sbhargavs
    Nov 14 '18 at 5:28














-1












-1








-1








Below is my Plain POJO object which is having all the mappings. Note that it is not an Entity object.



import javax.persistence.ColumnResult;
import javax.persistence.ConstructorResult;
import javax.persistence.NamedNativeQuery;
import javax.persistence.SqlResultSetMapping;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
@AllArgsConstructor
@SqlResultSetMapping(name = "refundReportMapping", classes = { @ConstructorResult(targetClass = RefundReport.class, columns = {
@ColumnResult(name = "customer_name"),
@ColumnResult(name = "hashed_email"), @ColumnResult(name = "address"),
@ColumnResult(name = "partner_order"),
@ColumnResult(name = "refund_amount") }) })
@NamedNativeQuery(name = "findRefundReportByStatusNamesParamsNative", query = "SELECT concat(bd.first_name,' ',bd.last_name) as 'customer_name',bd.email_address AS 'hashed_email',concat(bd.address1,' ',bd.address2) AS 'address',"
+ o.reservation_id AS 'partner_order',"
+ "(oa.principal_amount+oa.shipping_amount+oa.tax_amount) AS 'refund_amount'"
+ "FROM orders o, order_adjustments oa WHERE oa.status = :status"
+ "and o.buyer_detail_id=bd.buyer_detail_id and o.reservation_id=oa.order_id", resultClass = RefundReport.class, resultSetMapping = "refundReportMapping")
public class RefundReport {

private String customerName, email, address,
partnerOrder;
private BigDecimal partilaRefundAount;

}




public interface RefundReportRepository extends
Repository<RefundReport, String> {

List<RefundReport> findRefundReportByStatus(
@Param("status") String status);

}









share|improve this question
















Below is my Plain POJO object which is having all the mappings. Note that it is not an Entity object.



import javax.persistence.ColumnResult;
import javax.persistence.ConstructorResult;
import javax.persistence.NamedNativeQuery;
import javax.persistence.SqlResultSetMapping;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
@AllArgsConstructor
@SqlResultSetMapping(name = "refundReportMapping", classes = { @ConstructorResult(targetClass = RefundReport.class, columns = {
@ColumnResult(name = "customer_name"),
@ColumnResult(name = "hashed_email"), @ColumnResult(name = "address"),
@ColumnResult(name = "partner_order"),
@ColumnResult(name = "refund_amount") }) })
@NamedNativeQuery(name = "findRefundReportByStatusNamesParamsNative", query = "SELECT concat(bd.first_name,' ',bd.last_name) as 'customer_name',bd.email_address AS 'hashed_email',concat(bd.address1,' ',bd.address2) AS 'address',"
+ o.reservation_id AS 'partner_order',"
+ "(oa.principal_amount+oa.shipping_amount+oa.tax_amount) AS 'refund_amount'"
+ "FROM orders o, order_adjustments oa WHERE oa.status = :status"
+ "and o.buyer_detail_id=bd.buyer_detail_id and o.reservation_id=oa.order_id", resultClass = RefundReport.class, resultSetMapping = "refundReportMapping")
public class RefundReport {

private String customerName, email, address,
partnerOrder;
private BigDecimal partilaRefundAount;

}




public interface RefundReportRepository extends
Repository<RefundReport, String> {

List<RefundReport> findRefundReportByStatus(
@Param("status") String status);

}






java spring spring-boot spring-data-jpa spring-data






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 5:11









Jens Schauder

45.8k17112236




45.8k17112236










asked Nov 13 '18 at 14:52









sbhargavssbhargavs

11




11













  • The SqlResultSetMapping and NamedNativeQuery annotations need to be on an Entity, not on the non-entity POJO. stackoverflow.com/a/49536120/1116320

    – HaseebR7
    Nov 13 '18 at 16:15











  • I tried even that as well by providing the Entity, but it is expecting Identifier. My pojo dont have any Id column.

    – sbhargavs
    Nov 14 '18 at 5:06











  • I tried even that as well by providing the Entity, but it is expecting Identifier. My pojo don't have any Id column. So my question is can we define an Identifier in Entity without having ID id column in table.

    – sbhargavs
    Nov 14 '18 at 5:28



















  • The SqlResultSetMapping and NamedNativeQuery annotations need to be on an Entity, not on the non-entity POJO. stackoverflow.com/a/49536120/1116320

    – HaseebR7
    Nov 13 '18 at 16:15











  • I tried even that as well by providing the Entity, but it is expecting Identifier. My pojo dont have any Id column.

    – sbhargavs
    Nov 14 '18 at 5:06











  • I tried even that as well by providing the Entity, but it is expecting Identifier. My pojo don't have any Id column. So my question is can we define an Identifier in Entity without having ID id column in table.

    – sbhargavs
    Nov 14 '18 at 5:28

















The SqlResultSetMapping and NamedNativeQuery annotations need to be on an Entity, not on the non-entity POJO. stackoverflow.com/a/49536120/1116320

– HaseebR7
Nov 13 '18 at 16:15





The SqlResultSetMapping and NamedNativeQuery annotations need to be on an Entity, not on the non-entity POJO. stackoverflow.com/a/49536120/1116320

– HaseebR7
Nov 13 '18 at 16:15













I tried even that as well by providing the Entity, but it is expecting Identifier. My pojo dont have any Id column.

– sbhargavs
Nov 14 '18 at 5:06





I tried even that as well by providing the Entity, but it is expecting Identifier. My pojo dont have any Id column.

– sbhargavs
Nov 14 '18 at 5:06













I tried even that as well by providing the Entity, but it is expecting Identifier. My pojo don't have any Id column. So my question is can we define an Identifier in Entity without having ID id column in table.

– sbhargavs
Nov 14 '18 at 5:28





I tried even that as well by providing the Entity, but it is expecting Identifier. My pojo don't have any Id column. So my question is can we define an Identifier in Entity without having ID id column in table.

– sbhargavs
Nov 14 '18 at 5:28












1 Answer
1






active

oldest

votes


















0














There are multiple problems with this code.




  1. Repository needs two type parameters. The entity type it is a repository for and the type of the id type. Without stating these types Spring Data determines Object for both types which don't work because Object is not a managed entity. Also, if you intend to use RefundReport it needs to be a JPA managed entity.


  2. As pointed out by @HaseebR7 the annotations for named queries and the like must be on an entity as well.



Since it seems you just want to execute a query, you might use any entity, but it has to be a proper entity with an id.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53283670%2finvocation-of-init-method-failed-nested-exception-is-java-lang-illegalargumente%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    There are multiple problems with this code.




    1. Repository needs two type parameters. The entity type it is a repository for and the type of the id type. Without stating these types Spring Data determines Object for both types which don't work because Object is not a managed entity. Also, if you intend to use RefundReport it needs to be a JPA managed entity.


    2. As pointed out by @HaseebR7 the annotations for named queries and the like must be on an entity as well.



    Since it seems you just want to execute a query, you might use any entity, but it has to be a proper entity with an id.






    share|improve this answer




























      0














      There are multiple problems with this code.




      1. Repository needs two type parameters. The entity type it is a repository for and the type of the id type. Without stating these types Spring Data determines Object for both types which don't work because Object is not a managed entity. Also, if you intend to use RefundReport it needs to be a JPA managed entity.


      2. As pointed out by @HaseebR7 the annotations for named queries and the like must be on an entity as well.



      Since it seems you just want to execute a query, you might use any entity, but it has to be a proper entity with an id.






      share|improve this answer


























        0












        0








        0







        There are multiple problems with this code.




        1. Repository needs two type parameters. The entity type it is a repository for and the type of the id type. Without stating these types Spring Data determines Object for both types which don't work because Object is not a managed entity. Also, if you intend to use RefundReport it needs to be a JPA managed entity.


        2. As pointed out by @HaseebR7 the annotations for named queries and the like must be on an entity as well.



        Since it seems you just want to execute a query, you might use any entity, but it has to be a proper entity with an id.






        share|improve this answer













        There are multiple problems with this code.




        1. Repository needs two type parameters. The entity type it is a repository for and the type of the id type. Without stating these types Spring Data determines Object for both types which don't work because Object is not a managed entity. Also, if you intend to use RefundReport it needs to be a JPA managed entity.


        2. As pointed out by @HaseebR7 the annotations for named queries and the like must be on an entity as well.



        Since it seems you just want to execute a query, you might use any entity, but it has to be a proper entity with an id.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 5:09









        Jens SchauderJens Schauder

        45.8k17112236




        45.8k17112236






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53283670%2finvocation-of-init-method-failed-nested-exception-is-java-lang-illegalargumente%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()