#Extending ItemType vs @JdbcTypeCode(SqlTypes.JSON) - JPA/Hibernate

1 messages · Page 1 of 1 (latest)

quartz socket
#

Hey,

I've been wondering what a better solution would be? a new Entity that extends a ItemType in JPA
or a simple @JdbcTypeCode(SqlTypes.JSON) to convert a entire map/list to a json.

To convert to a json?

thanks!

stark vaporBOT
#

<@&987246584574140416> please have a look, thanks.

stark vaporBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

worn granite
#

better by what metric

quartz socket
#

Well thats a good question, i suppose whenever you wanna Query for a table, it requires be an entity. so in any sense where it doesn't require to be a table?

#

what is more verbose? i.e. overkill in computational cost? time?

worn granite
#

It depends on the context of the entity are. Querying a json field is ... doable but harder, often slower, than chasing entity references; it generally ties you to a specific DB, too, but eh.

quartz socket
#

But than again, for complex objects chasing an Entity reference still requires converting right? which is also quite heavy? in the case of extending ItemType for example?

worn granite
#

I'd have to measure for the case. "quite heavy" needs a lot of context, and JPA engines generally do that stuff quite well.

#

Are you talking to a relational database?

quartz socket
#

yeah, basically its for a game. a very big game actually so alot is loaded into memory on login.

#

so queries doesn't often happen, however i might for specific cases extend it to the website. ItemInventories for example.

worn granite
#

Well, what's the SLA

quartz socket
#

so theres not alot of relations

#

what is SLA?

worn granite
#

and the thing is, if speed is important then you've already kinda poured it down the drain for high throughput

#

what are your access requirements: N entities within M ms with user load of X ...

#

"I am accessing a database every four seconds, and it's okay if it takes 500ms to respond for that user" ... well... why bother optimizing? You'll waste more time optimizing than you'll ever care about

quartz socket
#

Right.

#

very true.

#

so yeah in my case only on login, so that would be depended on players logging in and out, which only happen every couple minutes

worn granite
#

I'm not saying NOT to optimize, but you probably shoudl focus on what you NEED to focus on before fapping away your time tuning a specific entity if it doesn't matter

quartz socket
#

right

worn granite
#

if it doesn't matter, do what you want, it'll work out

quartz socket
#

alright brother

#

thanks alot

#

for the advice

worn granite
#

my pleasure, hope it helps