question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

class declares multiple JSON fields named primaryKey

See original GitHub issue

Error:

java.lang.IllegalArgumentException: class run.flake.entities.database.users.UsersTable declares multiple JSON fields named primaryKey

Router:

get {
    val server = transaction {
        ServerRow.new {
            name = serverName
            owner = user
            members = SizedCollection(user)
        }
    }

    call.respond(transaction { server.toMap() }) // Here is error
}

.toMap():

fun <ID : Comparable<ID>> Entity<ID>.toMap2(): Map<String, Any?> {
	return this::class.declaredMemberProperties
		.associate {
			it.name to it.apply { isAccessible = true }.call(this)
		}
}

ServerRow

class ServerRow(id: EntityID<UUID>) : UUIDEntity(id) {
	companion object : UUIDEntityClass<ServerRow>(ServersTable)

	var name by ServersTable.name
	var description by ServersTable.description
	var members by UserRow via MembersTable
	var owner by UserRow referencedOn ServersTable.owner
	val groups by GroupRow referrersOn GroupsTable.server
	val roles by RoleRow referrersOn RolesTable.server
	var createdAt by ServersTable.createdAt
}

UserRow:

class UserRow(id: EntityID<UUID>) : UUIDEntity(id) {
	companion object : UUIDEntityClass<UserRow>(UsersTable)

	var lokin by UsersTable.lokin
	var password by UsersTable.password
	var username by UsersTable.username
	var region by UsersTable.locale
	var registeredAt by UsersTable.registeredAt
	var accessLevel by UsersTable.accessLevel
	var isBanned by UsersTable.isBanned
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ChA0S-f4mecommented, Nov 13, 2022

I started using jackson instead of GSON, after that it started working normally

0reactions
Tapaccommented, Sep 9, 2022

@xiaoliang-cn looks like you are trying to serialize UserTable with gson. Can you show the complete stacktrace to confirm it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

class A declares multiple JSON fields - Stack Overflow
1. You cannot have two fields with the same name. 2. You cannot have two fields with the same serialized name. 3. Types...
Read more >
class declares multiple JSON fields - How to tell Gson ... - GitHub
Hello, We are using Google Ad Manager axis API in our project. While converting LineItem object, we are getting the below error. java.lang....
Read more >
Mapping Multiple JSON Fields to One Java Field | Baeldung
First, we're going to use the @JsonProperty annotation, so that Jackson knows the name of the JSON field to map.
Read more >
Why Exclusion Strategy by name does not prevent “class ...
I am using GSON and getting "class Person declares multiple JSON fields named serialVersionUID", as the superclass of Person also has this ...
Read more >
com.google.gson.FieldAttributes.getDeclaringClass java code ...
Constructs a Field Attributes object from the f. hasModifier. Returns true if the field is defined with the modifier.This method is meant to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found