nightcall
nightcall

Reputation: 11

Cannot import javax.persistence.MapsId

I use Spring Data JPA and I would like to use the @MapsId annotation in the code of one of my entities

Although I put import javax.persistence.*; in my entity

I have the following compilation error :

cannot find symbol
[ERROR]   symbol:   method name()
[ERROR]   location: @interface javax.persistence.MapsId

My pom.xml is

<?xml version="1.0" encoding="UTF-8"?>
<project
    xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    ...

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
            <version>2.3.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.3.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.4.1210</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <version>2.3.4.RELEASE</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

Upvotes: 0

Views: 153

Answers (1)

cdalxndr
cdalxndr

Reputation: 1551

You are using @MapsId(name = "something"), but name doesn't exist on @MapsId.

Use value instead: @MapsId(value = "something"), or simply @MapsId("something")

Upvotes: 1

Related Questions