Storm Object Relational Mapping

@aljunggren aljunggren authored on 27 Sep 2020
src Added SetMapper, logic to read context.json, JSONUtils & tests 6 years ago
.gitignore Initial commit 6 years ago
README.md Added SetMapper, logic to read context.json, JSONUtils & tests 6 years ago
pom.xml Added SetMapper, logic to read context.json, JSONUtils & tests 6 years ago
README.md

Storm - Object-Relational Mapper

Interface

    @Database(context = "H2")
    private interface UserRepository {
        
        @Select(sql = "select * from users")
        public List<User> fetchAll();
        
        @Select(sql = "select * from users where id = ?")
        public User findById(int id);
        
        @Select(sql = "select firstname || ' ' || lastname from users")
        public List<String> fullNames();

    }

Context

  • src/main/resources/context.json
    [
        {
            "name" : "H2",
            "driver" : "org.h2.Driver",
            "url" : "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1",
            "username" : "",
            "password" : ""
        }
    ]

Use

    UserRepository repository = StormRepository.newInstance(UserRepository.class);
    
    List<User> users = repository.fetchAll();
    User user = repository.findById(12);
    List<String> fullNames = repository.fullNames();

Mapping

    @ColumnProperty(name = "employee_id")
    private int employeeID;