I'm trying to build a website in JDL Kotlin, but am having a problem with the JDL generated entities and edit forms. I have a JDL entity called Provider
, an entity called Plan
that needs to reference which provider it belongs to, and a third entity called PerDayPricing
that references both Provider
and Plan
, all as per the following JDL configuration:
entity Provider {
// [...]
}
entity Plan {
// [...]
}
entity PerDayPricing {
// [...]
}
relationship OneToMany {
Provider to Plan
}
relationship OneToMany {
Provider to PerDayPricing
Plan to PerDayPricing
}
service all with serviceImpl
However, when I try to create or set the Provider field on a Plan item, it spits out the following error:
WARN [PID] --- [ XNIO-1 task-10] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageConversionException: JSON conversion problem: Parameter specified as non-null is null: method com.example.project.domain.Plan.setPerDayPricings, parameter <set-?>; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Parameter specified as non-null is null: method com.example.project.domain.Plan.setPerDayPricings, parameter <set-?> (through reference chain: com.example.project.domain.Plan["perDayPricings"])]
PerDayPricing
is referenced here even though I didn't change any of its items. When I do try to set the Provider field on a PerDayPricing item, it gives the following error:
WARN [PID] --- [ XNIO-1 task-32] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageConversionException: JSON conversion problem: Parameter specified as non-null is null: method com.example.project.domain.Provider.setPlans, parameter <set-?>; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Parameter specified as non-null is null: method com.example.project.domain.Provider.setPlans, parameter <set-?> (through reference chain: com.example.project.domain.PerDayPricing["provider"]->com.example.project.domain.Provider["plans"])]
I actually have no idea what's going on here as I don't have a lot of experience with JHipster. I simply imported the JDL source file and let JHipster create files based on its configuration, without changing any of them, and this is already happening. References to the method names setPlans
and setPerDayPricings
don't even exist in the codebase, so I'm assuming they are being generated by Kotlin in the background?
Does anyone know what's going on and how I can fix it?
Edit: The following are the signatures of the entity classes (regular fields were removed for brevity):
// src/main/kotlin/domain/Provider.kt
@Entity
@Table(name = "plan")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
data class Plan(
// [...]
@OneToMany(mappedBy = "plan")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
var perDayPricings: MutableSet<PerDayPricing> = mutableSetOf(),
@OneToMany(mappedBy = "plan")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
var fixedDurationPricings: MutableSet<FixedDurationPricing> = mutableSetOf(),
@ManyToOne @JsonIgnoreProperties("plans")
var provider: Provider? = null
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
) : Serializable
// src/main/kotlin/domain/Plan.kt
@Entity
@Table(name = "provider")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
data class Provider(
// [...]
@OneToMany(mappedBy = "provider")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
var plans: MutableSet<Plan> = mutableSetOf(),
@OneToMany(mappedBy = "provider")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
var perDayPricings: MutableSet<PerDayPricing> = mutableSetOf(),
@OneToMany(mappedBy = "provider")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
var fixedDurationPricings: MutableSet<FixedDurationPricing> = mutableSetOf()
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
) : Serializable
// src/main/kotlin/domain/PerDayPricing.kt
/**
* A PerDayPricing.
*/
@Entity
@Table(name = "per_day_pricing")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
data class PerDayPricing(
// [...]
@ManyToOne @JsonIgnoreProperties("perDayPricings")
var provider: Provider? = null,
@ManyToOne @JsonIgnoreProperties("perDayPricings")
var plan: Plan? = null
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
) : Serializable