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

PropertyPath/PersistentProperty and Property Registration appending "-9XaHgsA"-like suffix to field names, causing "org.springframework.data.mapping.PropertyReferenceException" #2736

Closed
grice-globality opened this issue Nov 22, 2022 · 2 comments
Labels
status: duplicate A duplicate of another issue

Comments

@grice-globality
Copy link

This is for postgresql.
I've got an Entity that looks like this:


@Table("entity_type")
data class EntityType(
    @Id var id: UUID? = null,
    val entityTypeName: Name, // A string value class
    val systemSchemaVersion: SchemaVersion, // another string value class
)

And a table that looks like this:


    CREATE TABLE IF NOT EXISTS entity_type (
    id                      uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
    entity_type_name                    character varying NOT NULL,
    system_schema_version   character varying NOT NULL,

and accompanying interface:

interface EntityTypeRepository : CrudRepository<EntityType, EntityTypeIdType> {
    fun <S: EntityType> save(entity: S): EntityType
    fun findByEntityTypeName(entityTypeName: Name): EntityType?

I get this:

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property 'entityTypeName-9XaHgsA' found for type 'RuleType'
   at app//org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:91)
   at app//org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:438)
   at app//org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:414)
   at app//org.springframework.data.mapping.PropertyPath.lambda$from$0(PropertyPath.java:367)
   at [email protected]/java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:330)
   at app//org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:349)
   at app//org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:332)
   at app//org.springframework.data.repository.query.parser.Part.<init>(Part.java:81)

Why on EARTH is it appending "9XaHgsA" to the field/column name? It does this across ALL columns except the ID column.

Note that i'm using value classes, but that doesn't seem to cause a problem - they're automatically getting translated to strings as expected.

Also, note that this process goes through with the normal names first - I've stepped through in debugger - but then starts appending the 7 digit suffix for some reason second go-around.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 22, 2022
@mp911de
Copy link
Member

mp911de commented Nov 22, 2022

Why on EARTH is it appending "9XaHgsA"

That's an excellent question. Short answer: Take a look at your Kotlin inline class byte code with a bytecode analyzer. Long answer: #1947

@grice-globality
Copy link
Author

grice-globality commented Nov 23, 2022

@mp911de Thanks so much for getting back to me! I ended up digging into java-reflect and java-beans to try to figure out how that code got generated, and it's definitely there, not in your project, so you're absolutely right to close this down. I'm a new kotlin/java developer, though I'm quite experienced in Scala. This has been a fascinating learning experience about Java, bytecode, and reflection.

Again, I'm so touched you responded so quickly. Thank you! You're amazing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants