0

I have one spring boot application where I am fetching the data from my database table its one way not updating, for that I created one Entity class.

Now case if like that, where I wanted to added few more attributes into existing Entity[It is the JSON at the end], finally I am pushing the update JSON entity into destination system.

I just wanted to add more extra attributes which destination host wanted, and it is not coming from source table.

2
  • You have an existing JSON data in DB and want to add something in it and then want to save it as JSON, is it? Commented Jul 31, 2019 at 6:36
  • No DB has row level data only which I mapped with Entity class, I just wanted to add another attribute for destination as Spring GET method by default return JSON only, that is why I mentioned that to add additional attribute into JSON. Commented Jul 31, 2019 at 6:43

2 Answers 2

3

If you mean additional column in Entity class that you don't want to save into database, use @Transient.

@Transient
private String destination;

You can set the values but will only be transient and will not be from database.

If you want to add/merge another json check this.

Sign up to request clarification or add additional context in comments.

Comments

1

May be could be usefull for you add a new transient attribute on your entity that contains the json attributes (a custom object or the json value as String) Then create a new field on database to store the value.

If this attribute is a String it's all done but if not, if were a custom object, you should use the jpa annotations below to do the conversion object/json and json/object when create/update on database and load from database:

@PrePersist, @PreUpdate, @PostLoad

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.