0

// application.yml

spring:
  jpa:
    mapping-resources:
     - META-INF/mapper/ormMember.xml

// resources/META-INF/mapper/ormMember.xml

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm
                    http://xmlns.jcp.org/xml/ns/persistence/orm_2_2.xsd" version="2.2">

    <named-query name="findMember">
        <query>
            SELECT id FROM MEMBER
        </query>
    </named-query>

</entity-mappings>

I have set the above and used it like below It turned out like this

@Repository
@RequiredArgsConstructor
public class MembertRepositoryImpl {
    private final EntityManager em;

    public Member findMember() {
        Query q = em.createNamedQuery("findMember");
    }
}

but Cannot resolve query 'findApproval'

What settings do I need to add?

I tried the above, but it doesn't work.

dseoki
  • 1
  • Spring isn't JPA compliant, as with JPA you'd need to name the file and put it at META-INF/orm.xml and have a META-INF/persistence.xml file to define the persistence unit and have them get picked up. Since it is building the persistence.xml dynamically, presumably it will auto look for a META-INF/orm.xml file still - so you should try renaming yours instead of using the spring.jpa.mapping-resources property. – Chris May 24 '23 at 19:29

0 Answers0