Why is CrudRepository ignoring a @Column?

mike

I have an object model that looks like this:

public class Agreement {
    @Id @Column(name = "AGREEMENT_ID") private String agreementId;

    @Column(name = "RATE") private String rate;
    @Column(name = "NOTE") private String note;
    ... // A number of other fields
}

Each field has getters and setters, as generated by IntelliJ, verified these are all correct. On my GUI, the user has the option to make changes to an agreement, then hit "Save". Now my server needs to make the update on the back end. I'm using Spring Repositories and so I have:

@Repository
public interface AgreementRepository extends CrudRepository<Agreement, String> {}

When the user makes the submission I invoke agreementRepository.save(agreement). However, one of my fields, rate is not being updated on the back end.

I have stepped through the code and verified that the rate property is set correctly in the agreement object being passed to save(). Further, I have printed the SQL and verified that it is in fact at this level that the issue seems to be occurring, noting the save() method is calling a SELECT followed by UPDATE as expected since I'm modifying the same entry over and over in testing, but I can see clearly in the UPDATE part of the query that the rate field is not being set.

Odder still, ALL other fields are being set properly, regardless of whether I am also setting RATE or not. All other changes are propagating through just fine. There is nothing unusual about this RATE field. I thought maybe there was a bad trigger or something that a developer before me had put in, but I can see that the UPDATE SQL generated by Spring is clearly not setting it, and have verified no such triggers exist.

What is the reason that CrudRepository.save() would ignore one of my fields? It is not marked @Transient and is not unusual in any way. If it is not CrudRepository where else should I look to see why this field is not being set correctly?

mike

Here is the really wild part. It seems my issue was resolved by restarting IntelliJ. Really having a hard time understanding what went wrong.

I started by renaming the column in the DB to something else but leaving all other configs the same. I noted that no exception was being thrown and tried to figure out why, Spring Repository should be yelling at me for mis-configured entities. After a few more bizarre occurrences, I thought it would be best to restart IntelliJ, just in case.

Suddenly it correctly picked up the column was not correctly named. I renamed the column back to what it should be and everything is working as expected. Really bizarre.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Why is CrudRepository ignoring a @Column?

分類Dev

Extending CrudRepository, select all from one column?

分類Dev

Why is this query ignoring the WHERE clause?

分類Dev

Why is ansible ignoring this regexp in a lineinfile?

分類Dev

Why is flyway ignoring my SQL migration files?

分類Dev

why is ssh ignoring user config file

分類Dev

Concatenate column values in a pandas DataFrame while ignoring NaNs

分類Dev

Checking empty column values in case when and ignoring them

分類Dev

Why CrudRepository.save() ignore FetchType.EAGER when returning created object?

分類Dev

ClassNotFoundException CrudRepository

分類Dev

Why doesn't replacing paragraph content using method of ignoring of junk artifacts work?

分類Dev

Spring CrudRepository .orElseThrow()

分類Dev

Spring CrudRepositoryの例外

分類Dev

Is the CrudRepository .delete() method transactional?

分類Dev

CrudRepository の NullPointerException

分類Dev

Spring Hibernate-FindByObject CrudRepository

分類Dev

MySql TIMESTAMP column is auto updated. Why?

分類Dev

Why isn't the arrayformula applying to the entire column?

分類Dev

Why is the line number column missing in Atom?

分類Dev

Why I cannot assign foreign key to this column?

分類Dev

Why is my Bootstrap column not centering its content?`

分類Dev

OrderBy ignoring accented letters

分類Dev

OrderBy ignoring accented letters

分類Dev

SQL Ignoring WHERE clause

分類Dev

Ignoring NA values in function

分類Dev

Group By Ignoring NA

分類Dev

python ignoring if statement

分類Dev

MongoDB .limit() ignoring .sort()?

分類Dev

postgres is ignoring "-" when sorting

Related 関連記事

ホットタグ

アーカイブ