Jfinal's ActiveRecord Development example

Source: Internet
Author: User

Jfinal Original DB + Record mode example
Jfinal is equipped with the ActiveRecord plug-in, in addition to the implementation of similar rails Activerecrod functions, but also implemented a
DB + record mode, in which the developer can easily manipulate the database without even having to write the model.
The following is the sample code: // 创建name属性为James,age属性为25的User对象并添加到数据库 new User().set( "name" , "James" ).set( "age" , 25 ).save(); // 删除id值为25的User User.me.deleteById( 25 ); // 查询id值为25的User将其name属性改为James并更新到数据库 User.me.findById( 25 ).set( "name" , "James" ).update(); // 查询id值为25的user, 且仅仅取name与age两个字段的值 User user = User.me.findById( 25 , "name, age" ); // 获取user的name属性 String userName = user.getStr( "name" ); // 获取user的age属性 Integer userAge = user.getInt( "age" ); // 查询所有年龄大于18岁的user List<User> users = User.me.find( "select * from user where age > 18" ); // 分页查询sex为1并且年龄大于18的user,当前页号为1,每页10个user Page<User> userPage = User.me.paginate( 1 , 10 , "select *" , "from user where sex=? and age>?" , 1 , 18 );

Jfinal's ActiveRecord Development example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.