About EoD SQL
EoD SQL is a very small API (the JAR file weighs in at about 65k) that allows binding of SQL Queries to Java Objects. The API is designed to be compatible with the "Ease of Development" API that could be found in J2SE 1.6 beta, but not in the final release. The EoD API's main principal is that it maps SQL ResultSet's to objects, and not the other way around. Most OR mapping layers try to replicate the database structure in objects, where EoD SQL lets you write the SQL code, while it allows for easy access to Java Objects that map to the ResultSet.
Advantages to EoD SQL:
- Super light weight
- Very easy to work with
- Generally well documented (tell me where it's not)
- More features than the origional EoD RI
- No compile-time anything needed
- No XML, or other config files needed
- Should work with any JDBC database
- Lets you code whatever SQL you like
- Object mapping is loose (extra columns in the results are ignored, as are extra fields in the data object)
What EoD SQL is not:
- EoD SQL will not parse or validate your SQL in any way
- EoD SQL is not a database or database connector, it sits on top of JDBC
- EoD SQL will not get you girls
Code Example
The most important part of any API web page, is a code example:
public class User {
public Integer id;
private String username;
private String password;
// By default EoD SQL will look for a column with the
// same name as any public field, you can map the field to
// a different column-name with the @ResultColumn annotation
@ResultColumn("birth_date")
public Date birthDate;
public String getUsername() {
return username;
}
// @ResultColumn can also be used to mark setter methods
// that should be called during the mapping.
@ResultColumn("username")
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
@ResultColumn("password")
public void setPassword(String password) {
this.password = password;
}
}
// The Query interface
public interface UserQueries extends BaseQuery {
@Select("SELECT * FROM users WHERE password = ?1")
public DataSet<User> getUsersByPassword(String password);
@Select("SELECT * FROM users WHERE id = ?1")
public User getUserbyId(Integer id);
// Declaring SQLExceptions is entirely optional.If you don't declare them
// in a throws clause, they'll be wrapped in a RuntimeException for you.
@Update("UPDATE users SET username = ?{1.username}, " +
"password = ?{1.password}, birth_date = ?{1.birthDate} WHERE id = ?{1.id}")
public int updateUser(User user) throws SQLException;
}