[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

I have a java program that is able to retrieve information from

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 7
Thread images: 1

File: n-tier-architecture.jpg (71KB, 960x720px) Image search: [Google]
n-tier-architecture.jpg
71KB, 960x720px
I have a java program that is able to retrieve information from a relational database and convert it into objects it can work with. I was told (at least I though I was) not to let the Model layer know about the ID's used in the database.

However, now that I'm trying to communicate the other way, I realize that this is impossible because I need the ID's when I try to update the database when I make changes to the objects.

I guess I could theoretically make a hashmap that links all objects to their database ID, but that seems like a memoryleak catastrophe waiting to happen.

Anyone have any experience with this n - tier database stuff?
>>
>>55157035
Why wouldn't you let the Model layer know about the IDs used in the database?

I'm not sure how your ORM works exactly. Does it not have any documentation on how to update records using the ORM's API? Wouldn't this also mean that you'd be writing update queries without even utilizing the ORM layer?

Read the docs, anon
>>
>>55157139
I've written the ORM myself.

>Why wouldn't you let the Model layer know about the IDs used in the database?
I'm beginning to heavily ask myself that same question. I think I might have misread something like "don't heavily rely on database ID's in your Model layer" as "don't use ID's in your Model at all"..

Although.. I guess using ID's in your model makes it a bit harder to switch to a completely different type of database.

Right now I'm doubting between use being a bit unkosher and using ID's anyway or using a map and dealing with a shitton of garbage collection, which you shouldn't really be doing in Java. Feels wrong either way.
>>
>>55157035
I usually don't rely on id's because there is usually one field that must remain constant, such as a username or something, so I end up just indexing that field, lookup, and then set the PUT record's id field to the one I found in the db and then upsert it.
>>
>>55157251
If your ORM can select rows from a database, then it can use the primary key column as the ID

Your ORM needs to be able to have access to IDs, otherwise how would you be able to query/retrieve records based on DB keys?
>>
>>55157035
Check the java persistence API. Once you understood it you won't have problems with I'D/updates.
But sill in this persistence api you need a ID in your classes
>>
>>55157299
>>55157305
>>55157336
kk got it, adding IDs to my model objects as we speak

Thanks for the input guys. Appreciate it.
Thread posts: 7
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.