Skip to content

Field/column names getting appended with a dash and 7 characters, causing entity mapping and query projection to fail #803

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

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

Comments

@grice-globality
Copy link

grice-globality commented Nov 22, 2022

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 java.base@17.0.4/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
@grice-globality grice-globality changed the title Field/column names getting appended with random six letters, causing entity mapping and query projection to fail Field/column names getting appended with a dash and 7 characters, causing entity mapping and query projection to fail Nov 22, 2022
@mp911de
Copy link
Member

mp911de commented Nov 22, 2022

Closing as duplicate of spring-projects/spring-data-commons#2736.

@mp911de mp911de closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2022
@mp911de mp911de added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 22, 2022
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