DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

DEV Community ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป is a community of 963,274 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Braisdom
Braisdom

Posted on

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

Top comments (0)

๐ŸŒ™ Dark Mode?!

Turn it on in Settings