This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-06-11
Channels
- # admin-announcements (96)
- # beginners (102)
- # boot (51)
- # clojure (234)
- # clojure-art (1)
- # clojure-berlin (6)
- # clojure-brasil (1)
- # clojure-china (1)
- # clojure-germany (24)
- # clojure-italy (25)
- # clojure-japan (22)
- # clojure-russia (85)
- # clojure-sg (3)
- # clojure-spain (6)
- # clojure-uk (7)
- # clojure-ukraine (3)
- # clojurescript (108)
- # code-reviews (11)
- # core-typed (3)
- # datomic (6)
- # docs (13)
- # editors (121)
- # euroclojure (10)
- # events (2)
- # jobs (7)
- # ldnclj (77)
- # off-topic (27)
- # reading-clojure (8)
- # reagent (27)
- # robots (2)
- # slack-help (22)
Hi group.. What is the analogue of an ORM in the Clojure/functional world…a layer for managing entities and relationships among entities? In java i’d use something like Hibernate which would allow me to lazy load child objects on demand but I’m not sure how you would model this in Clojure. Can I get some pointers?
I had the same question when starting to build a logistics application recently. Took a serious look at this project
However, I found using clojure.java.jdbc quite efficient and may app wasn't 'large enough' to warrant the extra complexity of an ORM-type approach
@dilzio: other options are using DSL’s around relational database concepts e.g. http://sqlkorma.com/
if I had a simple map to insert/update as a row, that was v. straighforward with jdbc and if I had a more complex operation it is easier to express directly in sql
I know sql and don't want the extra bother of working out how to say something in sqlkorma dsl when I already know sql as a dsl!
I think most people favour dealing with basic data structures like maps or possibly records and therefore don’t feel the need for an ORM style library.
@matttylr: no neither do I really. I suspect people hand craft traversal using map/reduce?
so yeah what i’m looking for is to understand how i can model an object graph with a functional language
the key thing that i want to do be able to easily retrieve relationships. So for example… let’s say i have a data model with a many to one relationship of members to organization. in java/hibernate i’d do something like organization.getMembers() to retrieve it. I guess in clojure i’d need to do something like (getMembers orgid) ?
what I need however is to define declaratively the entity relationship in an edm file then have a framework that could read that
I've not used it myself, but the guides talk about denormalisation and data duplication being encouraged
@dilzio: I’m a beginner too but whenever I catch myself modelling data in an OO paradigm I suspect I’m doing it wrong!
I've often found the same. If I ask 'how do I do this in clojure world', the answer is often 'you dont need to!'
I imagine you've seen this: http://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling
one of the requirements is that i can specify my entities declaratively so i need the notion of entities… i do not however have to store them in a purely normalized canonical relational model
however in some cases it may make sense to do so…that’s part of what i’m trying to figure out as part of the whole ball of wax
but if you 'Model Around Your Queries' then really you're pushing that 'entity modelling' concern down to the database layer, leaving your clojure code to pull back data in the shape that you need it
the way you write data (especially in the case of systems like cassandra) is naturally different the way its retrieved
that’s a good point. Maybe this is less of a clojure question and more of a pure modeling question (insert lightbulb emoji here)
Maybe we need an intermediates channel? 😉
Oh joy, more channels to monitor!
I stopped visiting the IRC #C03S1KBA2 channel because is was just too busy. Very hard to follow.
I’m currently reading the beta version of https://pragprog.com/book/vmclojeco/clojure-applied to get a steer on issues like when to use records vs maps, etc. (plug for @alexmiller)
@dmich: well you can buy the beta version now. We could ask @alexmiller if he thinks he’s on target for a mid November publishing date.
Clojure Applied should be out in August - it's in final tech review now
The current beta has all but one chapter
@alexmiller: Thanks Alex. I’m enjoying the first chapter so far. I’ll let you have any comments/questions but so far all is good.
Thanks! If you do find issues, please file them in the errata page at the prag site - we track them there and you can see when it's fixed etc
@alexmiller: will do
Anyone using Atom editor (http://atom.io) for clojure development?
@andrewvida: There’s an #C050AN6QW channel. Might get more traction there.
great! Thanks @akiva! I’ll ask in there.
@yusup i am using timbre, but also look at that library https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fpyr%2Funilog&sa=D&sntz=1&usg=AFQjCNHt2QDY999FQzxDMpWi4puYJjHVMA
Sorry, i don't know. Never looked after that. Maybe read the instructions or ask the maintainer?
A very mutable question, but what would you use for a simple CRUD web app in Clojure / how would you structure the back-end?
Thanks, @markstang!
@markstang: I find it cleaner to use :dbtype
/ :dbname
most times: `
(def db {:dbtype "postgres" :dbname "CybershopDB_2" :user "postgres" :password "postgres" :port 5432})
I’m convincing myself that I need to use korma, maybe to do some creative macro stuff one day to customize the SQL queries, since it’s easier with a s-exp… 😃
Take a look at HoneySQL if you want composable queries-as-sexps
(linked from java.jdbc docs)
I should default 5432 for PostgreSQL really in java.jdbc...
@seancorfield: Thanks!
We use HoneySQL extensively for complex reporting queries at World Singles. My colleague gave a talk on it at Clojure/West.
@barton: I build a very basic crud plugin: https://github.com/sveri/closp-crud using korma and selmer, it's part of closp: https://github.com/sveri/closp
@seancorfield: I watched that talk, looked interesting, though I haven’t had an opportunity to try it out yet.
I quite like honeysql as well
It's a very good 90% solution and has proven easy to modify. Its biggest lack is coherent documentation, honestly.
@donaldball: That’s a valid criticism for a lot of Clojure libraries I’m afraid. I find I spend a lot of time reading source code for many of the libraries I use.
True dat. We developers are — in general — not awfully good at documentation 😞
It's almost as if technical writing and software development were distinct disciplines
@seancorfield: @donaldball therefore, I find it easiest to understand clojure code, compared to other languages, it's almost as reading docs