Micronaut Data JDBC Repository function name conflict

31 Views Asked by At

Using Micronaut Data JDBC I have two entities:

@MappedEntity("action")
data class ActionEntity(
 @Id @AutoPopulated
 val id: UUID? = null,
 @Relation(Relation.Kind.ONE_TO_ONE)
 @JoinColumn(name = "id")
 val webhookAction: WebhookActionEntity? = null
)

@MappedEntity("webhook_action")
data class WebhookActionEntity(
 @Id val actionId: UUID,
 val url: String
)

To fetch the webhookAction object inside the ActionEntity I need to add a @Join annotation on the Repository implementation like so:

@JdbcRepository(dialect = Dialect.POSTGRES)
interface ActionRepository : CrudRepository<ActionEntity, UUID> {

 @Join(value = "webhookAction")
 fun findById(actionId: UUID): List<ActionEntity>
}

But from my understanding this will now always do a join on the webhook_action table as well. I want to be able to get ActionEntity objects as well without doing doing joins.

I don't mind naming my function something else, but it's based on the Micronaut query name standard. Is there a way of adding some suffix like findByIdWithWebhookAction without getting an issue with the function name needing to comply with the query syntax?

0

There are 0 best solutions below