apache / apache/grails-core

Gorm 6.1 JPA @Version duplication

Open
#14,541 1 comment 0 reactions 0 assignees View on GitHub
relates-to: gorm
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

In migrating a grails 3.2.11 app to 3.3.8, which migrates to Gorm 6.1, JPA annotated entities no longer work.

TagLink.groovy
```
import javax.persistence.*;
import javax.validation.constraints.Min;

@Entity
@Table(name = "tag_links")
public class TagLink {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch=FetchType.EAGER, cascade = [CascadeType.REFRESH, CascadeType.PERSIST, CascadeType.MERGE])
@JoinColumn(name = "tag_id")
private Tag tag;

@Column(name = "tag_ref")
@Min(0L)
private Long tagRef;

@Column(name = "type", nullable = false)
private String type;

@Version
private Long version;
...
```

Fails on build with:

The method public java.lang.Long getVersion() { ... } duplicates another method of the same signature
. At [-1:-1] @ line -1, column -1.

All of my JPA entities that have an @Version annotation fail.

I would assume if Gorm 6.1 supports JPA annotations, it should handle the @Version annotation.

Contributor guide

Open the contributing guide

Research direction

Start with the TagLink.groovy example and reproduce the Gorm 6.1 build failure during the Grails 3.3.8 migration. Inspect how JPA entities with @Version are handled and compare the generated getVersion methods. Done means entities using @Version build without the reported duplicate-method error.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.