Automatically convert user submitted forms to SQL using Form-sql-builder-mysql

Source: Internet
Author: User
Tags sql using

Automatically convert user submitted forms to SQL using Form-sql-builder-mysql

Maven Dependency

<dependency>  <groupId>org.crazycake</groupId>  <artifactId> Form-sql-builder-mysql</artifactid>  <version>1.0.0-RELEASE</version></dependency>

Quick Start

STEP 1. Create a rule file

Under Classpath, create a folder called Formsqlrules, which is created under this folder Global.json

{"Global": [{"Field": "String:*", "Op": "Like", "rel": "and"},{"field": "*:*", "op": "=", "rel": "and"}]}
STEP 2. Create a test with a PO class

public class Person {private Integer activestatus;private string name;private integer age;private string city;public perso N (string name, Integer age, String city, Integer activestatus) {this.name = Name;this.age = Age;this.city = City;this.activ Estatus = Activestatus;} Public Integer Getactivestatus () {return activestatus;} public void Setactivestatus (Integer activestatus) {this.activestatus = Activestatus;} Public String GetName () {return name;} public void SetName (String name) {this.name = name;} Public Integer Getage () {return age;} public void Setage (Integer age) {this.age = age;} Public String getcity () {return city;} public void Setcity (String city) {this.city = city;}}

STEP 3. Call Formsqlbuilder

person form = new Person ("Jack", "$", "NY", 1); Formsqlbuilder B = new Formsqlbuilder (form, "global"); B.addlimit (1, 20); Sqlandparams s = b.build (); System.out.println (S.getsql ()); for (Object V:s.getparams ()) {System.out.println (v);}
Console output

SELECT * from who WHERE name like? And city like? and Active_status =? and age =?  LIMIT 0,20jackny136
More specific about the

    • Syntax and optional values for rules
    • Use of wildcard characters
    • Scope Query
    • Group queries
    • Add limit
    • Add sort
    • In query
See the GitHub website



Automatically convert user submitted forms to SQL using Form-sql-builder-mysql

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.