Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properties with type of Kotlin inline class has mangled name. [DATAGRAPH-1330] #1891

Closed
spring-projects-issues opened this issue Jun 30, 2020 · 4 comments
Assignees
Labels
in: ogm status: declined

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Jun 30, 2020

Corneil du Plessis opened DATAGRAPH-1330 and commented

I wanted to use an ``inline class` for the type of an Id to ensure I avoid using a non ID property in a query or when comparing etc.

Kotlin mangles the name of the property when it's type is an inline class an @Property doesn't seem to take effect.

https://github.com/corneil/demo-inline-class-property-bug

 

No property userId-kArDf24 found for type User!

 

Do I need a converter for the inline class when the property is found?


Attachments:

Issue Links:

1 votes, 4 watchers

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Aug 21, 2020

Michael Simons commented

While this request here wouldn't work with pure OGM at the moment, the issue experience here is not a Spring Data Neo4j issue. 

The exception happens in Spring Data Commons while parsing the property path. I would like to drag Mark into this and let him decide if that is something VMWare wants to support or not

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Aug 21, 2020

Michael Simons commented

For reference, here's a stack trace 

 

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property userId-1a1a7c8 found for type User!Caused by: org.springframework.data.mapping.PropertyReferenceException: No property userId-1a1a7c8 found for type User! at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:94) ~[spring-data-commons-2.3.3.RELEASE.jar:2.3.3.RELEASE] at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:382) ~[spring-data-commons-2.3.3.RELEASE.jar:2.3.3.RELEASE] at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:358) ~[spring-data-commons-2.3.3.RELEASE.jar:2.3.3.RELEASE] at org.springframework.data.mapping.PropertyPath.lambda$from$0(PropertyPath.java:311) ~[spring-data-commons-2.3.3.RELEASE.jar:2.3.3.RELEASE] at java.base/java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:330) ~[na:na] at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:293) ~[spring-data-commons-2.3.3.RELEASE.jar:2.3.3.RELEASE] at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:276) ~[spring-data-commons-2.3.3.RELEASE.jar:2.3.3.RELEASE] at org.springframework.data.repository.query.parser.Part.<init>(Part.java:82) ~[spring-data-commons-2.3.3.RELEASE.jar:2.3.3.RELEASE] at org.springframework.data.repository.query.parser.PartTree$OrPart.lambda$new$0(PartTree.java:251) ~[spring-data-commons-2.3.3.RELEASE.jar:2.3.3.RELEASE]

 

And I have attached an actual failing example, too.

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Aug 23, 2020

Mark Paluch commented

Kotlin synthesizes property accessors such as:

public final void setUserId-uoTQERM(@Nullable String <set-?>) {
  this.userId = <set-?>;
}

Another issue is that there's no public all args constructor as Kotlin creates only a no-arg constructor, the all-arg constructor is made private:

public User() {}
private User(String userId, String email, String fullName) {
  this.userId = userId;
  this.email = email;
  this.fullName = fullName;
}

That being said, the design of Kotlin inline classes regarding JVM library interoperability is broken by design and I don't see how we can fix it from a Spring perspective. I attached a decompiled variant of the user class

@michael-simons
Copy link
Collaborator

@michael-simons michael-simons commented Jan 12, 2021

So it seems that we cannot do much here and therefore we are gonna close this ticket.

@michael-simons michael-simons added status: declined and removed type: bug labels Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: ogm status: declined
Projects
None yet
Development

No branches or pull requests

3 participants