DEV Community

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)