Vinay Pandey
Vinay Pandey

Reputation: 451

Hibernate Mapping Exception: Repeated column mapping for entity,

I know this question has been asked manytimes and i went through the solutions but couldnt get the idea of where iam missing. Please find below the entities for which Iam getting the issue.

@Entity
@Table(name = "debit_file", schema = "test")
public class DebitFile  extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "test.debit_file_seq")
@SequenceGenerator(name = "test.debit_file_seq", sequenceName = "test.debit_file_seq", allocationSize = 1)
@Column(name = "id")
private Long id;

@Column(name = "file_name")
private String fileName;

@Column(name = "file_path")
private String filePath;

@Column(name = "no_of_records")
private int noOfRecords;

@Column(name = "no_of_records_processed")
private int noOfProcessedRecords;

@Column(name = "no_of_records_unprocessed")
private int noOfUnprocessedRecords;

@Column(name = "created_at")
private Date createdDate;

@Column(name = "status")
private String status;

@OneToMany(fetch = FetchType.EAGER)
@JoinColumn(name = "file_id", referencedColumnName = "id", updatable = false, insertable = false)
private List<DebitFileRecord> debitFileRecordList = new ArrayList<>();

 getters() and setters() below...
}

Second enity class as below:

@Entity
@Table(name="debit_file_record", schema = "test")
public class DebitFileRecord {

@Id
@GeneratedValue(generator = "UUID")
@GenericGenerator(name="UUID", strategy="org.hibernate.id.UUIDGenerator")
@Column(name="id" , updatable = false, nullable = false)
private UUID id;

@Column(name="transaction_date")
private Date transactionDate;

@Column(name="account_number")
private String accountNumber;

@Column(name="record")
private String record;

@Column(name="status")
private String status;

@Column(name="error_message")
private String errorMessage;

@Column(name = "file_id")
private Long fileId;

getters() and setters below...
}

As shown in the above code it is avery simple mapping but iam still getting

repeated column mapping for entity DebitFile column: created_at 
(should be mapped with insert="false" update="false").

I dont see any error in the code. Can someone please help me understand the issue.

Upvotes: 0

Views: 70

Answers (1)

Ken Chan
Ken Chan

Reputation: 90447

Several things to check :

  1. Does the BaseEntity also include another field which are mapped to "created_at" ?
  2. Does the DebitFile or the BaseEntity has any getter that are mapped to "created_at" ?

If yes for (1) , remove createdDate from DebitFile as it is already defined in the BaseEntity.

If yes for (2) , remove the mapping from the getter as it is already defined in the field.

Upvotes: 1

Related Questions