News for hackers. Stuff that matters.
Re:Gotchas, Irritants and Warts in Go Web Development by tptacek on Thursday March 07, 2013 @05:28PM (#5340793)
This; the moment I realized I was never going to choose to do CRUD web stuff in Go was when I realized that this was the perspective Golang developers have on ORMs.
Re:Gotchas, Irritants and Warts in Go Web Development by mbreese on Thursday March 07, 2013 @05:37PM (#5340838)
That's funny... knowing that ORMs aren't everywhere actually makes me more likely to use Go. I still have Hibernate flashbacks.
Re:Gotchas, Irritants and Warts in Go Web Development by lobster_johnson on Saturday March 09, 2013 @08:48PM (#5350350)
Hibernate is not a good example of an ORM, frankly. (I myself have horrors of both Hibernate and TopLink, which was the top Java ORM way back when.)

Ruby's ActiveRecord is a much better choice. It has an excellent balance between SQL and OO. It doesn't pretend that SQL doesn't exist; on the contrary, it encourgaes SQL use, and merely maps tables to objects, adds a bunch of useful features (data validation, change management, automatic joins, declarative migrations) and gets out of your way most of the time.

For example:

    users = User.where("created_at > ?", Time.now - 1.year).
      order('name').limit(10)
Results are lazily loaded and composable, so you can do:

    users = User.where("created_at > ?", Time.now - 1.year)
    if (page = params[:page])
      users = users.offset((page - 1) * 10).limit(10)
    end
Joining is easy:

    users = Users.joins(:accounts).
      where(accounts: {type: 'facebook')).first
becomes something like:

    select users.*
    from users
    join accounts on accounts.id = users.account_id
    where accounts.type = 'facebook'
    limit 1
Re:Gotchas, Irritants and Warts in Go Web Development by boundlessdreamz on Friday March 08, 2013 @12:16PM (#5344515)
Have you used rails ORM (activerecord) or sqlalchemy ? (I haven't used the latter much but people rave about it). Hibernate is an ORM taken to the extremes