What would be the closest equivalent in Java to a Micro ORM such as Dapper, PetaPoco, Massive or Cod...

What would be the closest equivalent in Java to a Micro ORM such as Dapper, PetaPoco, Massive or CodingHorror?

share improve this question

closed as off-topic by Laurel, manetsus, Lambda Ninja, Compass, Edvin Tenovimas Aug 6 '16 at 6:57

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – Laurel, manetsus, Lambda Ninja, Compass, Edvin Tenovimas
If this question can be reworded to fit the rules in the help center, please edit the question.
 
10  
Ooh, good question – Marc Gravell Jun 27 '11 at 15:11
3  
@Marc: Exactly. There're many projects that port out of Java projects. These MicroORMs are ones that could be ported from .net to Java. – Robert Koritnik Jun 28 '11 at 16:24
   
@Robert: It would be great to see some of the good .Net work heading the other way too, for sure. – Kynth Sep 6 '11 at 16:20

up vote 20 down vote accepted

I recommend Spring JDBC templates. While it's not a "true" ORM, it's a pleasure to use where Hibernate seems to be an overkill.

share improve this answer
 
2  
it sounds like a good fit, then ;p Dapper, PetaPoco and Massive are also not "true" ORMs - they instead concentrate on doing an insanely good job of simple data access, which covers a high % of use-cases. – Marc Gravell Jun 29 '11 at 12:15
2  
queryForObject seems a bit clunky, can that not be done with generics in java? eg: Query<Car>("select * from Cars") ? – Sam Saffron Jul 4 '11 at 1:33
2  
@sam-saffron Yes! Use SimpleJdbcTemplete - static.springsource.org/spring/docs/2.0.x/reference/… – Arnelism Jul 11 '11 at 16:04

sql2o seems like a Dapper alternative - thin wrapper around JDBC

String sql =
    "SELECT id, category, duedate " +
    "FROM tasks " +
    "WHERE category = :category";
Sql2o sql2o = new Sql2o(DB_URL, USER, PASS);
List<Task> tasks = sql2o.createQuery(sql)
    .addParameter("category", "foo")
    .executeAndFetch(Task.class);

github - https://github.com/aaberg/sql2o

site - http://www.sql2o.org/

share improve this answer
 
1  
I would say that sql2o is the easiest and small framework to treat queries like insert, update, delete. I've been using it since 1 year smoothly, however there's not any major update since 2015. It is missing a functionality to treat view and joins in one query to avoid round trips to db. – Maximus Decimus Jul 7 '17 at 0:52

Here's a list of tools that "ease the pain" when interacting with simple JDBC:

And here's a list of tools that go a bit beyond simple JDBC, i.e. provide some ORM / ActiveRecord facilities

  • jOOQ (This one probably doesn't qualify as micro-ORM)
  • JaQu
  • ActiveJDBC (This one is more of an ActiveRecord API, than an ORM)
  • MyBatis (This one focuses on SQL templating, but also has some mapping features)
  • EBean
share improve this answer
 
   
I've been using sql2o for 1 year without any trouble. However there is no major update since 2015!!!!! I hope this library doesn't get obsolete. It is PLAIN AND SIMPLE to use. However I think the creator was requesting ideas to treat VIEWS and/or JOIN queries since so long. I checked quickly this list and Apache DbUtils it is the more closest to sql2o. – Maximus Decimus Jul 7 '17 at 0:45
   
@MaximusDecimus: If you're such a fan of sql2o, why abandon it instead of contributing? You could even become its new maintainer! – Lukas Eder Jul 7 '17 at 8:14

Another interesting light ORM is JDBI. Here is Five minute intro

It has two alternative APIs:

Fluent API

DBI dbi = new DBI(ds);
Handle h = dbi.open();

String name = h.createQuery("select name from something where id = :id")
                    .bind("id", 1)
                    .map(StringMapper.FIRST)
                    .first();

and SQL Object API where SQL statements are mapped to methods with declarative interfaces like this:

public interface MyDAO
{
  @SqlUpdate("create table something (id int primary key, name varchar(100))")
  void createSomethingTable();
}

DBI dbi = new DBI(ds);
MyDAO dao = dbi.open(MyDAO.class);
dao.createSomethingTable();
share improve this answer
 
   
pro tip: you can mix both approaches using abstract class instead of interface in object api – tomaszkubacki Oct 18 '13 at 1:03
   
That SQL Object API looks super cool! – jjnguy Jan 16 '14 at 2:23

Also checkout SimpleFlatMapper

It's a performant simple ResultSet to Object mapper. It just plug on top of jdbc and gives far better performance than Hibernate Ibatis or even sql2o. It easily integrate JdbcTemplate and provides constructor, setter and field injection.

share improve this answer
 
   
May I know what are the disadvantages of SimpleFlatMapper compared to Spring's own BeanPropertyRowMapper? – Yudhistira Arya Sep 11 '14 at 15:42

This one doesn't seem to be mentioned here yet: dalesbred

Similar to sql2o and dapper...

share improve this answer
 
   
I should also mention that sql2o seems more active. The API for sql2o seems a bit more natural to me. Dalesbred supports WHERE ... IN queries whereas sql2o does not for now. – jl. Oct 7 '15 at 18:15

转载于:https://www.cnblogs.com/yasepix/p/8176398.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值