New around here? Register your SA Forums Account here!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.

TheFluff posted:

query builders/sql metaprogramming tools are usually p dang handy on the application side though. SQLAlchemy, jOOQ, that sort of thing.
can confirm jOOQ is the poo poo
can confirm (N)Hibernate is poo poo

with hibernate you need to be so careful designing your entities that your domain model usually has to change in order to fit the orm than the other way around. and if you need multiple lazy loading/fetching settings depending on the query then good luck with that. just add more annotations you better not gently caress up

Adbot
ADBOT LOVES YOU

CPColin
Sep 9, 2003

Big ol' smile.

Finster Dexter posted:

cjs: just finished a shouting match between me, CTO, and CEO... choice CEO quote: "small, quick tasks will always be higher priority than bigger tasks even though the small tasks might be less important from a business standpoint."

oh ok let me just interrupt the frontend work on our new platform version so frontend dev can spend 10 minutes adjusting a font size on the old version that will be obsolete in 3 weeks.

:suicide:

Sounds like they need a scrummaster to yell at instead!

Powerful Two-Hander
Mar 9, 2004
Probation
Can't post for 3 hours!
honestly given how easy sql actually is I struggle to think of a case where a full fat orm is actually a benefit. like dapper owns because you can a use it as just an auto mapper and save some boilerplate, and yeah you can do stuff like embed lambas to split dataset outputs but you know what? If you're doing that poo poo you need to look at your data source queries and think "am I being too clever here?"


just write some procs that query views and if its slow either unfuck your query to not return a billion rows in an embedded expression then distinct them (!) or add the index you probably forgot about because you were gonna come back and add them after you created the table but db janitoring is boring so you didn't

edit: select em all 1989, I am ANSI man, 27193736 returned rows

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

i feel like i know juuust enough about the pitfalls of relational databases that the idea of an ORM makes me do the :chloe: face. i would be constantly checking the SQL output of the ORM if i used one, so uh at that point is there even any benefit?

CPColin
Sep 9, 2003

Big ol' smile.
Ignore what the ORM puts out until a new query floats to the top of your database monitor's "Bad Queries" report, imo.

Powerful Two-Hander
Mar 9, 2004
Probation
Can't post for 3 hours!

CPColin posted:

Ignore what the ORM puts out until a new query floats to the top of your database monitor's "Bad Queries" report, imo.

but with so many bad queries how would you choose???

CPColin
Sep 9, 2003

Big ol' smile.
Choose whichever query your boss wrote

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof
99 times out of 100 i'd rather work with a shallow api on top of raw sql than an orm

the 1 time an orm works falls apart like 1 business requirement later

but there's often a reasonable sql builder solution somewhere between raw sql strings and a full blow orm

prisoner of waffles
May 8, 2007

Ah! well a-day! what evil looks
Had I from old and young!
Instead of the cross, the fishmech
About my neck was hung.

DaTroof posted:

99 times out of 100 i'd rather work with a shallow api on top of raw sql than an orm

the 1 time an orm works falls apart like 1 business requirement later

but there's often a reasonable sql builder solution somewhere between raw sql strings and a full blow orm

username/post combo

redleader
Aug 18, 2005

Engage according to operational parameters
gently caress the query optimiser though

Beamed
Nov 26, 2010

Then you have a responsibility that no man has ever faced. You have your fear which could become reality, and you have Godzilla, which is reality.


pseudorandom posted:

I'm both a couple days late and too lazy right now to actually investigate your code, but is there any reason you're going lower-level with hyper/tokio rather than one of the higher level frameworks? Rocket was really easy for simple projects, but I've moved over to Actix for my more recent toy projects. I would definitely recommend using a framework for Rust web things, unless your project is a web framework itself.
I posted about getting burned really hard by this a few months back, to the point where I wanted to write my own framework - it was at the height of the panic over Actix's tons of unsafe blocks, Rocket still being Too Unstable, and Gotham being abandoned (temporarily). Rust's web story still doesn't seem to be there.

pseudorandom posted:

Look at this guy, graduating high school in 3 years.


I was 7-11.


I was probably 7-11 too, but years are hard :smith:

Powerful Two-Hander posted:

honestly given how easy sql actually is I struggle to think of a case where a full fat orm is actually a benefit. like dapper owns because you can a use it as just an auto mapper and save some boilerplate, and yeah you can do stuff like embed lambas to split dataset outputs but you know what? If you're doing that poo poo you need to look at your data source queries and think "am I being too clever here?"


just write some procs that query views and if its slow either unfuck your query to not return a billion rows in an embedded expression then distinct them (!) or add the index you probably forgot about because you were gonna come back and add them after you created the table but db janitoring is boring so you didn't

edit: select em all 1989, I am ANSI man, 27193736 returned rows

EF is cool when you have to write an OData-compliant API oh god why

ThePeavstenator
Dec 18, 2012

:burger::burger::burger::burger::burger:

Establish the Buns

:burger::burger::burger::burger::burger:

more like NOData

floatman
Mar 17, 2009
I would rather work on a system with bad Devs misusing ORM rather than a system where bad Devs misuse SQL.
With bad ORM you still have the option to drop down to SQL to try to save something, but with just SQL the cancer has settled down to the bone.

MononcQc
May 29, 2007

if you can’t replace a resource’s storage from a database to a remote service without changing all the loving application logic everywhere then you hosed up your isolation and abstraction layers and you gotta go back and rethink that interface

the view or controllers in an app should have no loving clue whether you’re using an ORM or not for the data model or handling. if you do, congratulations you’ve built everything on top of a leaky abstraction.

go sit in a corner and think about what you’ve done

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

elcannon posted:

Probably the most useful take I've gotten from reading this thread over the years is that the application layer has no business owning the database layer and that ORMs inevitably end up with people blowing off their own foot and then just shrugging it off because at least they don't have to touch SQL.

counterpoint: people who dogmatically avoid ORM just wind up implementing one themselves badly

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

prisoner of waffles posted:

so glad I don't work with EF anymore

Entity Framework was a hastily-created me-too response to Hibernate and Core Data

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

MononcQc posted:

if you can’t replace a resource’s storage from a database to a remote service without changing all the loving application logic everywhere then you hosed up your isolation and abstraction layers and you gotta go back and rethink that interface

the view or controllers in an app should have no loving clue whether you’re using an ORM or not for the data model or handling. if you do, congratulations you’ve built everything on top of a leaky abstraction.

go sit in a corner and think about what you’ve done

once again with the wisdom

this has been something I’ve tried to teach people with the Core Data code generation feature in Xcode 8 & later

like, it’ll generate classes for your entities at build time, and you can just import the headers and use them, add extensions/categories on them, and so on, and all that is great to get code completion, business logic, and so on

but what we don’t do is let you expose those classes as public or even private API, only as internals within your module, in part because you really shouldn’t be exposing build-time generated code (which can change from release to release) as API

if you’re going to expose it the least you could do is invoke the static code generator (it’s just a menu item, we didn’t take it away) and put the results in your project as “real” sources with comments and API versioning markup and all that good stuff

(or better, don’t, and think more carefully about the API you’re exposing to clients)

pseudorandom
Jun 16, 2010



Yam Slacker
Edit: Removed; I'm probably too inexperienced/dumb to comment on this.

I'll keep this from my original post:

I'll admit, I've never worked in an Enterprise environment, so maybe I just don't Get It.

pseudorandom fucked around with this message at 05:12 on Apr 10, 2019

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
at least one of the advantages of a good ORM is that it can enforce constraints at both the database and application level by letting them be specified in one place

some attribute has a length restriction, or a formatting restriction? specify it in the model and it can flow to both the database (regardless of back-end) and to the UI (regardless of the front end)—this was the huge advantage of NeXT’s Enterprise Objects Framework for both AppKit and WebObjects application development

you can also batch multiple modifications to the object graph into coherent updates, so either the whole changeset goes through or doesn’t, and you can get intelligent reporting as to why a particular changeset failed to apply (such as an optimistic locking failure, a constraint violation where some custom bit of UI didn’t actually read from the model, etc.); yes you can get this from transactions too, but again this is phrased in terms of your model and can be easily reflected in the UI

in Core Data and EOF we also took advantage of this to allow things like automatic maintenance of inverse relationships, automatic serialization & deserialization of object properties to database-compatible representations, automatic support of (both infinite and batched) undo for modeled properties, and the ability to nest changesets

animist
Aug 28, 2018
i love query builders but really any sort of janky metaprogramming bullshit is cocaine to me so my judgement probably shouldn't be trusted

HoboMan posted:

guess who got two thumbs and found plaintext passwords in the database?

hows that going for you

crazysim
May 23, 2004
I AM SOOOOO GAY

Beamed posted:

I posted about getting burned really hard by this a few months back, to the point where I wanted to write my own framework - it was at the height of the panic over Actix's tons of unsafe blocks, Rocket still being Too Unstable, and Gotham being abandoned (temporarily). Rust's web story still doesn't seem to be there.


i've been using rouiille. it's synchronous but its fast enough to tide me over and let me use other more mature parts of the rust ecosystem until something matures. just internal tools only though.

redleader
Aug 18, 2005

Engage according to operational parameters

pseudorandom posted:

Edit: Removed; I'm probably too inexperienced/dumb to comment on this.

I'll keep this from my original post:

I'll admit, I've never worked in an Enterprise environment, so maybe I just don't Get It.

if everyone "too inexperienced/dumb to comment" decided not to post, yospos would be a wasteland. :justpost:, and maybe some of us will learn something new, or see another side of a debate, or hear about another perspective

animist
Aug 28, 2018

redleader posted:

if everyone "too inexperienced/dumb to comment" decided not to post, yospos would be a wasteland. :justpost:, and maybe some of us will learn something new, or see another side of a debate, or hear about another perspective

here's another perspective

goatse.jpg

Aramoro
Jun 1, 2012




eschaton posted:

counterpoint: people who dogmatically avoid ORM just wind up implementing one themselves badly

This.

If you're doing a CRUD app but using raw SQL you'll need to implement an Object-Statement mapper, a Statement-Object mapper, concurrency/versioning, aliasing, fetch strategy, caching, a statement mapper for different dialects if that's your bag etc. You've just written your own lovely ORM.

The the decade or so we've been using Hibernate we've never had an issue related to how Hibernate generates querys. The closest we've had to a bug was when SQL Server wasn't query caching the parameterised queries correctly. But that turned out to be a config/JDBC driver problem.

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.

Aramoro posted:

The the decade or so we've been using Hibernate we've never had an issue related to how Hibernate generates querys. The closest we've had to a bug was when SQL Server wasn't query caching the parameterised queries correctly. But that turned out to be a config/JDBC driver problem.
well let me just say you are clearly in the wrong thread, sir!

Aramoro
Jun 1, 2012




Sagacity posted:

well let me just say you are clearly in the wrong thread, sir!

One of our current front ends still uses Struts 1.6, I've got plenty of terrible to go around.

Aramoro
Jun 1, 2012




Finster Dexter posted:

cjs: just finished a shouting match between me, CTO, and CEO... choice CEO quote: "small, quick tasks will always be higher priority than bigger tasks even though the small tasks might be less important from a business standpoint."

oh ok let me just interrupt the frontend work on our new platform version so frontend dev can spend 10 minutes adjusting a font size on the old version that will be obsolete in 3 weeks.

:suicide:

We've got a big task in the backlog to replace our home-rolled Lucene search with Solr. It's basically ready to go, probably a couple of weeks effort in porting stuff over. But it's constantly getting bumped out of iterations for things like styling changes and lovely new features. It's probably the biggest improvement we can make to the application in terms of platform just now but customers can't 'see' it so we're not doing it. It's just absolutely infuriating.

Chalks
Sep 30, 2009

Beamed posted:

EF is cool when you have to write an OData-compliant API oh god why

we use microsoft's odata library and i'm sure it made it easy for them to write but holy gently caress ef is a loving disaster in this project.

ef can take a good 10-15 seconds to prepare a query it's never seen before, and in odata new queries happen all the time. sure, ef has some great caching so once it's calculated it once it'll be super fast, but odata aggregates leak cache entries and the ef cache can only hold 800 items. to make matters worse, the ef cache sweep that triggers once it hits 800 items is so brutal that if you regularly hit this limit it will dump the entire cache causing every single query to rebuild no matter how regularly it was hit.

it was so bad that we had to decompile ef to change the cache handling to make it less of an rear end in a top hat. that combined with branching the microsoft odata project to fix some dumb bugs in that and to get our ef dll to run means our odata solution is a loving clown car of projects.

gently caress odata and gently caress microsoft's inability to write a single coherent codebase for their "open standard".

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.
is anyone really using odata outside microsoft (and companies that drank microsoft's koolaid)? asking for a friend

i recently spent some time odata'ing because i needed to connect to the azure graph api and it was okay, i guess. being able to specify which fields to include is nice, but there are all sorts of bizarre restrictions on which nested relationships you can follow and which ones you can't etc

Chalks
Sep 30, 2009

Sagacity posted:

is anyone really using odata outside microsoft (and companies that drank microsoft's koolaid)? asking for a friend

i recently spent some time odata'ing because i needed to connect to the azure graph api and it was okay, i guess. being able to specify which fields to include is nice, but there are all sorts of bizarre restrictions on which nested relationships you can follow and which ones you can't etc

a bunch of things have connectors for it out of the box which makes it better than a random roll your own api. that said, the only ones people actually use in my experience are the excel and power bi connectors so it is pretty much microsoft all the way down.

Shaggar
Apr 26, 2006

eschaton posted:

counterpoint: people who dogmatically avoid ORM just wind up implementing one themselves badly

in which case they have created exactly the same thing as every other orm and lost nothing

Shaggar
Apr 26, 2006
the only thing i know about odata is that Microsoft graph uses it and Microsoft graph is slow as gently caress

Shaggar
Apr 26, 2006

eschaton posted:

at least one of the advantages of a good ORM is that it can enforce constraints at both the database and application level by letting them be specified in one place

some attribute has a length restriction, or a formatting restriction? specify it in the model and it can flow to both the database (regardless of back-end) and to the UI (regardless of the front end)—this was the huge advantage of NeXT’s Enterprise Objects Framework for both AppKit and WebObjects application development

you can also batch multiple modifications to the object graph into coherent updates, so either the whole changeset goes through or doesn’t, and you can get intelligent reporting as to why a particular changeset failed to apply (such as an optimistic locking failure, a constraint violation where some custom bit of UI didn’t actually read from the model, etc.); yes you can get this from transactions too, but again this is phrased in terms of your model and can be easily reflected in the UI

in Core Data and EOF we also took advantage of this to allow things like automatic maintenance of inverse relationships, automatic serialization & deserialization of object properties to database-compatible representations, automatic support of (both infinite and batched) undo for modeled properties, and the ability to nest changesets

if you're applying validation in the model and not in the orm how is the orm helping you? also the entity layer in ef is absolutely the worst part about it because you spend more time writing code to manage entities in memory than you ever would have writing sql w/ a statement mapper.

Shaggar
Apr 26, 2006

MononcQc posted:

if you can’t replace a resource’s storage from a database to a remote service without changing all the loving application logic everywhere then you hosed up your isolation and abstraction layers and you gotta go back and rethink that interface

the view or controllers in an app should have no loving clue whether you’re using an ORM or not for the data model or handling. if you do, congratulations you’ve built everything on top of a leaky abstraction.

go sit in a corner and think about what you’ve done

typical orm use is to not do any abstraction and use orm code in your controllers. this is because orms are promoted as that thing that does the abstraction between the application and data source.

statement mappers are litterrally a way to map your abstraction interfaces to statements in your data store.

DELETE CASCADE
Oct 25, 2017

i haven't washed my penis since i jerked it to a phtotograph of george w. bush in 2003
the object-relational impedance mismatch isn't a real thing, just write the drat sql (using a query builder obvs not raw strings)

TheFluff
Dec 13, 2006

FRIENDS, LISTEN TO ME
I AM A SEAGULL
OF WEALTH AND TASTE
hibernate seems to have the worst of both worlds; you have queries as strings, but they're not sql, they're some idiot pseudo-sql :psyduck:

akadajet
Sep 14, 2003

I'm using ef core on a small service right now and it's very needs suiting.

Aramoro
Jun 1, 2012




TheFluff posted:

hibernate seems to have the worst of both worlds; you have queries as strings, but they're not sql, they're some idiot pseudo-sql :psyduck:

Only if you choose to use HQL, queries are not string in general for the last maybe 10-11 years? If you're using an statement mapper then you're already writing pseudo-sql.

Terrible Programmer : I need to 'see' the SQL getting run to ensure it's correct, I just don't trust it!

Also Terrible Programmer : *use a SQL query builder and statement mapper*

crazypenguin
Mar 9, 2005
nothing witty here, move along

MononcQc posted:

the view or controllers in an app should have no loving clue whether you’re using an ORM or not for the data model or handling. if you do, congratulations you’ve built everything on top of a leaky abstraction.

go sit in a corner and think about what you’ve done

fwiw, this is just typical, though

You're absolutely right, but I've never met a web app that wasn't just handing views ORM-based model objects to extract data out of.

I have this theory that our programming languages just aren't good enough at quickly and easily describing intermediate data types (and transforming to/from them) that we all just tend to skip doing that pretty aggressively. :effort:

DELETE CASCADE posted:

the object-relational impedance mismatch isn't a real thing, just write the drat sql (using a query builder obvs not raw strings)

it's real, it's just a lot narrower than people give it credit for. "don't try to match tables 1:1 with classes, because projection and joins," well golly.

Adbot
ADBOT LOVES YOU

HoboMan
Nov 4, 2010

animist posted:

hows that going for you

asked the client about it and the client says they are using "microsoft" for the application validation so don't worry about it

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply