DEV Community

Braisdom
Braisdom

Posted on

2 2

The Challenge of the ORM in Java(Simple querying)

The ObjectiveSQL is a new ORM framework, it enhances the existed ORM framework capability, the first is simple querying.

Definition of domain model

@DomainModel
public class Blog {
    private Long id;
    private String title;
    private Integer state;

    @Relation(relationType = RelationType.BELONGS_TO)
    private Author author;
}
Enter fullscreen mode Exit fullscreen mode

In MyBatis:

<mapper>
  <resultMap type="Blog" id="blog">
    <id column="id" property="id" />
    ...
    <association property="author" javaType="Author">
      ...
    </association>
  </resultMap>
  <select id="findBlog" parameterType="int" resultMap="blog">
    ...
  </select>
</mapper>
Enter fullscreen mode Exit fullscreen mode
...
BlogMapper mapper = session.getMapper(BlogMapper.class); 
Blog blog = mapper. findBlog(...);
Enter fullscreen mode Exit fullscreen mode

In ObjectiveSQL:

Blog blog = Blog.queryByPrimaryKey(1, Blog.BELONGS_TO_AUTHOR);
Enter fullscreen mode Exit fullscreen mode

https://github.com/braisdom/ObjectiveSql

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay