> What ORM do people use that influences the structure of their database?
Hibernate and JPA encourage designing your domain classes first and then generate the DDL from that.
> Also, the ORM allows me to specify models that are not only used for structuring the database, but also for validation of incoming JSON requests and easily serialize queries back to JSON.
Postgres has great JSON support, does the ORM something with JSON that Postgres cannot do?
> Hibernate and JPA encourage designing your domain classes first and then generate the DDL from that.
This is a feature, not requirement or need of the ORM. It seems pretty silly to let the existence of a feature prevent you from making designing the structure of your DB correctly.
> does the ORM something with JSON that Postgres cannot do?
Postgres's json functionality is used for manipulating and querying data stored in the DB.
I believe the poster is talking about deserializing and validating json from REST requests and serializing json for REST responses using the mapping defined for the ORM.
> I believe the poster is talking about deserializing and validating json from REST requests and serializing json for REST responses using the mapping defined for the ORM.
These are also things that the json functionality of Postgres can do. For example, look at to_json and json_agg.
In my current company I use Postgres JSONB with Hibernate extensively. One of the benefits of the ORM is that json fields can be constrained to a fixed schema. For example, a tag list field can be a SortedSet of strings.
A couple other things I've learned:
* Never re-use complex types in both your API and your schema. These things evolve at different paces and you should never have to worry that a change to your schema will break an API (or vice-versa). The minimal extra typing to have dedicated API types is well worth it.
* Storing untrusted client-submitted JSON in your database is a terrible idea. This is a great attack surface, either by DOSing your system with large blobs or by guessing keys that might have meaning in the future.
Hibernate and JPA encourage designing your domain classes first and then generate the DDL from that.
> Also, the ORM allows me to specify models that are not only used for structuring the database, but also for validation of incoming JSON requests and easily serialize queries back to JSON.
Postgres has great JSON support, does the ORM something with JSON that Postgres cannot do?