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

Java Micro ORM equivalent [closed]

Ask Question


up vote 51 down vote favorite

21

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

java subsonic dapper petapoco massive


shareimprove this question

edited Jun 11 ‘12 at 15:24

asked Jun 27 ‘11 at 15:05

Kynth

1,8881224

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

add a comment

6 Answers

active oldest votes


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.


shareimprove this answer

answered Jun 27 ‘11 at 22:49

Arnelism

9331918

 

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

add a comment


up vote 23 down vote

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/


shareimprove this answer

answered Aug 9 ‘13 at 7:58

tomaszkubacki

1,59011226

 

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

add a comment


up vote 12 down vote

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

shareimprove this answer

edited Sep 7 ‘13 at 10:25

answered Sep 7 ‘13 at 10:04

Lukas Eder

114k63383771

 

    

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

add a comment


up vote 4 down vote

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();

shareimprove this answer

answered Aug 23 ‘13 at 3:13

tomaszkubacki

1,59011226

 

    

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

add a comment


up vote 3 down vote

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.


shareimprove this answer

answered Sep 1 ‘14 at 10:34

Anaud Roger

311

 

    

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

add a comment


up vote 2 down vote

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

Similar to sql2o and dapper...


shareimprove this answer

answered Aug 11 ‘15 at 5:40

jl.

576415

 

    

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

时间: 2024-11-05 12:28:12

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

LeetCode 16 3Sum Closest(C,C++,Java,Python)

Problem: Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution. For example, given array S

【LeetCode】3Sum Closest 解题报告 (Java)

[题目] Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution. For example, given array S = {

[LeetCode] 016. 3Sum Closest (Medium) (C++/Java/Python)

索引:[LeetCode] Leetcode 题解索引 (C++/Java/Python/Sql) Github: https://github.com/illuz/leetcode 016.3Sum_Closest (Medium) 链接: 题目:https://oj.leetcode.com/problems/3sum-closest/ 代码(github):https://github.com/illuz/leetcode 题意: 在给定数列中找出三个数,使和最接近 target. 分析:

LeetCode算法题-Maximize Distance to Closest Person(Java实现)

这是悦乐书的第328次更新,第351篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第198题(顺位题号是849).在一排座位中,1表示一个人坐在该座位上,0表示座位是空的.在这些座位中,至少有一个空座位,至少有一个人坐着.Alex想坐在座位上,以便他和离他最近的人之间的距离最远.返回距离最近的人的最大距离.例如: 输入:[1,0,0,0,1,0,1] 输出:2 说明:如果Alex坐在第二个空座位(seats[2]),那么离最近的人距离为2.如果Alex坐在任何其他空

Hibernate——Java 领域的持久化ORM框架

Hibernate教程 https://www.w3cschool.cn/hibernate/skzl1idz.html Hibernate是一个开源,轻量级的ORM(对象关系映射)工具.Hibernate框架简化了java应用程序与数据库交互的开发. ORM工具简化了数据创建,数据处理和数据访问.它是将对象映射到数据库中存储的数据(表)的编程技术. 狭义的理解,“持久化”仅仅指把对象永久保存到数据库中 广义的理解,“持久化”包括和数据库相关的各种操作: 保存:把对象永久保存到数据库中. 更新:

Weed3 for java 新的微型ORM框架

Weed3,微型ORM框架(支持:java sql,xml sql,annotation sql:存储过程:事务:缓存:监听:等...) 05年时开发了第一代: 08年时开发了第二代,那时候进入互联网公司,对性能有了全新的认识: 14年时开发了第三代.因为不喜欢滥用反射,不喜欢有很多配置,所以一直在执着的没放弃. 前两代,都是在.net开发的:第三代,重点放在了java上.应该算是个功能全面且最小的ORM框架,无其它依赖,仅0.1mb.对外的接口也不多,主要由DbContext上的四个接口发起所

Java NIO SocketChannel

Java Nio 1 Java NIO Tutorial 2 Java NIO Overview 3 Java NIO Channel 4 Java NIO Buffer 5 Java NIO Scatter / Gather 6 Java NIO Channel to Channel Transfers 7 Java NIO Selector 8 Java NIO FileChannel 9 Java NIO SocketChannel 10 Java NIO ServerSocketChan

Java编程思想(十二) —— 字符串(2)

上篇讲到String的基本用法及StringBuilder和String的比较.继续. 给大家感受一下RednaxelaFX的厉害,他大学看的书. 嗯,这就是去硅谷的水平,所以,还是继续看书吧. 1)格式化输出 确实,说到C的printf,是不能用重载的+操作符的. printf("%d %f", x , y); %d这些为格式修饰符,%d表示整数,x插入到%d的位置,%f表示浮点数,y查到%f的位置. Java也模仿了C: public class TestString { publ

Scala程序设计-Java虚拟机多核编程实践(一)

对象一旦创建出来,就不再改变其内容,这样的对象是不变的.这样做可以无需顾虑多线程访问对象时的竞争管理,Java的String就是不变对象的一个例子.基于此,使用Scala创建多线程应用时,可以用不变状态(immutable state)编写无锁代码,从而写出简洁的多线程代码,而无需顾虑线程间的数据竞争,以及处理加锁和释放带来的梦魇. JVM上的其他语言Groovy.JRuby.Clojure怎么样呢?目前为止,能够同时提供函数式风格和良好并发支持的强类型语言,唯有Scala. Scala是Sca