Я работаю с jhipster, у меня есть следующий формат jdl:
![enter image description here](https://i.stack.imgur.com/Y2ymc.png)
Я сделал некоторые изменения в доменах, которые выглядят как :
@Entity
@Table(name = "client_account")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class ClientAccount implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private Long id;
@NotNull
@Column(name = "first_name", nullable = false)
private String firstName;
@NotNull
@Column(name = "last_name", nullable = false)
private String lastName;
@NotNull
@Column(name = "phone", nullable = false)
private String phone;
@Column(name = "identity")
private String identity;
@Column(name = "referal")
private String referal;
@Column(name = "refered_by")
private String referedBy;
@OneToOne
@MapsId
private User user;
@OneToMany(mappedBy = "clientAccount")
private Set<Reputation> reputations = new HashSet<>();
@OneToMany(mappedBy = "clientAccount")
private Set<Trip> trips = new HashSet<>();
и домен репутации:
@Entity
@Table(name = "reputation")
public class Reputation implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotNull
@Column(name = "rate", nullable = false)
private Integer rate;
@Column(name = "comment")
private String comment;
@ManyToOne
@JsonIgnoreProperties("reputations")
private TransporterAccount transporterAccount;
@ManyToOne
@JsonIgnoreProperties("reputations")
private ClientAccount clientAccount;
Домен пользователя:
@Entity
@Table(name = "jhi_user")
public class User extends AbstractAuditingEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotNull
@Pattern(regexp = Constants.LOGIN_REGEX)
@Size(min = 1, max = 50)
@Column(length = 50, unique = true, nullable = false)
private String login;
@JsonIgnore
@NotNull
@Size(min = 60, max = 60)
@Column(name = "password_hash", length = 60, nullable = false)
private String password;
@Size(max = 50)
@Column(name = "first_name", length = 50)
private String firstName;
@Size(max = 50)
@Column(name = "last_name", length = 50)
private String lastName;
@Email
@Size(min = 5, max = 254)
@Column(length = 254, unique = true)
private String email;
@NotNull
@Column(nullable = false)
private boolean activated = false;
@Size(min = 2, max = 10)
@Column(name = "lang_key", length = 10)
private String langKey;
@Size(max = 256)
@Column(name = "image_url", length = 256)
private String imageUrl;
@Size(max = 20)
@Column(name = "activation_key", length = 20)
@JsonIgnore
private String activationKey;
@Size(max = 20)
@Column(name = "reset_key", length = 20)
@JsonIgnore
private String resetKey;
@Column(name = "reset_date")
private Instant resetDate = null;
@JsonIgnore
@ManyToMany
@JoinTable(
name = "jhi_user_authority",
joinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "authority_name", referencedColumnName = "name")})
@BatchSize(size = 20)
private Set<Authority> authorities = new HashSet<>();
Liquidibase Transporter отображается следующим образом:
<changeSet id="20200218210800-1" author="jhipster">
<createTable tableName="client_account">
<column name="user_id" type="bigint">
<constraints primaryKey="true" nullable="false"/>
</column>
<column name="first_name" type="varchar(255)">
<constraints nullable="false" />
</column>
<column name="last_name" type="varchar(255)">
<constraints nullable="false" />
</column>
<column name="phone" type="varchar(255)">
<constraints nullable="false" />
</column>
<column name="identity" type="varchar(255)">
<constraints nullable="true" />
</column>
<column name="referal" type="varchar(255)">
<constraints nullable="true" />
</column>
<column name="refered_by" type="varchar(255)">
<constraints nullable="true" />
</column>
<!-- jhipster-needle-liquibase-add-column - JHipster will add columns here, do not remove-->
</createTable>
</changeSet>
<changeSet id="20200218210800-2" author="jhipster">
<addForeignKeyConstraint baseColumnNames="user_id"
baseTableName="client_account"
constraintName="fk_client_account_user_id"
referencedColumnNames="id"
referencedTableName="jhi_user"/>
</changeSet>
и репутация liquibase:
<changeSet id="20200218210700-1-data" author="jhipster" context="faker">
<loadData
file="config/liquibase/fake-data/reputation.csv"
separator=";"
tableName="reputation">
<column name="id" type="numeric"/>
<column name="rate" type="numeric"/>
<column name="comment" type="string"/>
<!-- jhipster-needle-liquibase-add-loadcolumn - JHipster (and/or extensions) can add load columns here, do not remove-->
</loadData>
</changeSet>
<changeSet id="20200218210700-2" author="jhipster">
<addForeignKeyConstraint baseColumnNames="transporter_account_id"
baseTableName="reputation"
constraintName="fk_reputation_transporter_account_id"
referencedColumnNames="user_id"
referencedTableName="transporter_account"/>
<addForeignKeyConstraint baseColumnNames="client_account_id"
baseTableName="reputation"
constraintName="fk_reputation_client_account_id"
referencedColumnNames="user_id"
referencedTableName="client_account"/>
</changeSet>
Тем не менее я получаю следующую ошибку: репутация0_.comment как комментарий2_14_, репутация0_.rate как оценка3_14_, репутация0_.transporter_account_user_id как транспортный_5_14_ из репутации репутация0_ порядок по репутации0_.id как предел c? [42122-200] 2020-02-20 09: 48: 03.515 ОШИБКА 23616 --- [XNIO-1 task-7] c .a.dropme.aop.logging.LoggingAspect: Исключение в com.abdrid.dropme. service.ReputationQueryService.findByCriteria () с причиной = 'org.hibernate.exception.SQLGrammarException: не удалось подготовить оператор', а исключение = 'не может подготовить оператор; SQL [выберите репутацию0_.id в качестве id1_14_, репутацию0_.client_account_user_id в качестве client_a4_14_, репутацию0_.comment в качестве комментария2_14_, репутацию0_.rate в качестве показателя3_14_, репутацию0_.transporter_account_user_id в качестве транспортера 5_14_ из репутации * 0): 0_0 вложенным исключением является org.hibernate.exception.SQLGrammarException: не удалось подготовить оператор '