Spring Data native Query support

classic Classic list List threaded Threaded
3 messages Options
niamin niamin
Reply | Threaded
Open this post in threaded view
|

Spring Data native Query support

Does Ignite provide native Query support using Spring Data? I am not able to
bootstrap my application when I configure my Repository to include a method
that implements a native query as below:

@Repository
@RepositoryConfig(cacheName = "FOO")
public interface ARInvoiceRepository
        extends IgniteRepository<ARInvoice, ARInvoiceId> {
    @Query(value = "SELECT * FROM AR_INVOICE i where i.customerId =
:customerId " +
            "and i.installmentFl = 'N' and i.excludeFromArFl = 'N' and
((i.installmentNo > 0 " +
            "and i.installmentStartDt <= :toDate) or i.tranDt <= :toDate)
and i.status != 'H' ",
            nativeQuery = true)
    List<ARInvoice> getInvoicesForOIStatement(@Param("customerId") String
customerId, @Param("toDate") Date statementDate);
}

When I start my application I get an error as below:

Caused by: java.lang.IllegalArgumentException: Not a managed type: class
com.gpc.rpm.bo.ARInvoice
        at
org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:473)
~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
        at
org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:73)
~[spring-data-jpa-2.0.9.RELEASE.jar:2.0.9.RELEASE]
        at
org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:66)
~[spring-data-jpa-2.0.9.RELEASE.jar:2.0.9.RELEASE]
        at
org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:180)
~[spring-data-jpa-2.0.9.RELEASE.jar:2.0.9.RELEASE]
        at
org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:118)
~[spring-data-jpa-2.0.9.RELEASE.jar:2.0.9.RELEASE]
        at
org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:101)
~[spring-data-jpa-2.0.9.RELEASE.jar:2.0.9.RELEASE]
        at
org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:304)
~[spring-data-commons-2.0.14.RELEASE.jar:2.0.14.RELEASE]
        at
org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$4(RepositoryFactoryBeanSupport.java:290)
~[spring-data-commons-2.0.14.RELEASE.jar:2.0.14.RELEASE]
        at org.springframework.data.util.Lazy.getNullable(Lazy.java:141)
~[spring-data-commons-2.0.14.RELEASE.jar:2.0.14.RELEASE]
        at org.springframework.data.util.Lazy.get(Lazy.java:63)
~[spring-data-commons-2.0.14.RELEASE.jar:2.0.14.RELEASE]
       

I've added @Entity annotation to ARInvoice class but that didn't change the
error.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
dmagda dmagda
Reply | Threaded
Open this post in threaded view
|

Re: Spring Data native Query support

It’s possible to pass an Ignite native query to a method but you might need to configure the repository differently. Please check this documentation:


Denis

On Wednesday, October 30, 2019, niamin <[hidden email]> wrote:
Does Ignite provide native Query support using Spring Data? I am not able to
bootstrap my application when I configure my Repository to include a method
that implements a native query as below:

@Repository
@RepositoryConfig(cacheName = "FOO")
public interface ARInvoiceRepository
        extends IgniteRepository<ARInvoice, ARInvoiceId> {
    @Query(value = "SELECT * FROM AR_INVOICE i where i.customerId =
:customerId " +
            "and i.installmentFl = 'N' and i.excludeFromArFl = 'N' and
((i.installmentNo > 0 " +
            "and i.installmentStartDt <= :toDate) or i.tranDt <= :toDate)
and i.status != 'H' ",
            nativeQuery = true)
    List<ARInvoice> getInvoicesForOIStatement(@Param("customerId") String
customerId, @Param("toDate") Date statementDate);
}

When I start my application I get an error as below:

Caused by: java.lang.IllegalArgumentException: Not a managed type: class
com.gpc.rpm.bo.ARInvoice
        at
org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:473)
~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
        at
org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:73)
~[spring-data-jpa-2.0.9.RELEASE.jar:2.0.9.RELEASE]
        at
org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:66)
~[spring-data-jpa-2.0.9.RELEASE.jar:2.0.9.RELEASE]
        at
org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:180)
~[spring-data-jpa-2.0.9.RELEASE.jar:2.0.9.RELEASE]
        at
org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:118)
~[spring-data-jpa-2.0.9.RELEASE.jar:2.0.9.RELEASE]
        at
org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:101)
~[spring-data-jpa-2.0.9.RELEASE.jar:2.0.9.RELEASE]
        at
org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:304)
~[spring-data-commons-2.0.14.RELEASE.jar:2.0.14.RELEASE]
        at
org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$4(RepositoryFactoryBeanSupport.java:290)
~[spring-data-commons-2.0.14.RELEASE.jar:2.0.14.RELEASE]
        at org.springframework.data.util.Lazy.getNullable(Lazy.java:141)
~[spring-data-commons-2.0.14.RELEASE.jar:2.0.14.RELEASE]
        at org.springframework.data.util.Lazy.get(Lazy.java:63)
~[spring-data-commons-2.0.14.RELEASE.jar:2.0.14.RELEASE]


I've added @Entity annotation to ARInvoice class but that didn't change the
error.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


--
-
Denis

ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Spring Data native Query support

In reply to this post by niamin
Hello!

Judging from stack trace, you ended up with Hibernate repository and not with Ignite repository.

Regards,
--
Ilya Kasnacheev


ср, 30 окт. 2019 г. в 23:25, niamin <[hidden email]>:
Does Ignite provide native Query support using Spring Data? I am not able to
bootstrap my application when I configure my Repository to include a method
that implements a native query as below:

@Repository
@RepositoryConfig(cacheName = "FOO")
public interface ARInvoiceRepository
        extends IgniteRepository<ARInvoice, ARInvoiceId> {
    @Query(value = "SELECT * FROM AR_INVOICE i where i.customerId =
:customerId " +
            "and i.installmentFl = 'N' and i.excludeFromArFl = 'N' and
((i.installmentNo > 0 " +
            "and i.installmentStartDt <= :toDate) or i.tranDt <= :toDate)
and i.status != 'H' ",
            nativeQuery = true)
    List<ARInvoice> getInvoicesForOIStatement(@Param("customerId") String
customerId, @Param("toDate") Date statementDate);
}

When I start my application I get an error as below:

Caused by: java.lang.IllegalArgumentException: Not a managed type: class
com.gpc.rpm.bo.ARInvoice
        at
org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:473)
~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
        at
org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:73)
~[spring-data-jpa-2.0.9.RELEASE.jar:2.0.9.RELEASE]
        at
org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:66)
~[spring-data-jpa-2.0.9.RELEASE.jar:2.0.9.RELEASE]
        at
org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:180)
~[spring-data-jpa-2.0.9.RELEASE.jar:2.0.9.RELEASE]
        at
org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:118)
~[spring-data-jpa-2.0.9.RELEASE.jar:2.0.9.RELEASE]
        at
org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:101)
~[spring-data-jpa-2.0.9.RELEASE.jar:2.0.9.RELEASE]
        at
org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:304)
~[spring-data-commons-2.0.14.RELEASE.jar:2.0.14.RELEASE]
        at
org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$4(RepositoryFactoryBeanSupport.java:290)
~[spring-data-commons-2.0.14.RELEASE.jar:2.0.14.RELEASE]
        at org.springframework.data.util.Lazy.getNullable(Lazy.java:141)
~[spring-data-commons-2.0.14.RELEASE.jar:2.0.14.RELEASE]
        at org.springframework.data.util.Lazy.get(Lazy.java:63)
~[spring-data-commons-2.0.14.RELEASE.jar:2.0.14.RELEASE]


I've added @Entity annotation to ARInvoice class but that didn't change the
error.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/