public class Bridge<A> extends Object
Defines a data bridge that is responsible for object persistence to a database. This object relational mapper is optimised to work with POJOs respecting these behaviors:
When an object is passed to any of the Bridge's insert, update, delete of fill method, the object is assumed to be a persistable entity. The name of the class is assumed to be the name of a table and the object's properties are assumed to be the table's columns.
Note for case sensitive RDBMS
Do not forget to match the capitalization from your class names to your table
names. Further more properties are camelcased. For example, take the
hypotetic property "first name" (getFirstName() and setFirstName() methods).
This property is assumed to match the column name "firstName".
| Constructor and Description |
|---|
Bridge(Class<A> type,
String... ignoredProperties)
Creates a new Bridge using the default connection string as defined in
the "bridge.xml" file.
|
Bridge(Connection connection,
Class<A> type,
String... ignoredProperties)
Creates a new Bridge using the default connection string as defined in
the "bridge.xml" file.
|
| Modifier and Type | Method and Description |
|---|---|
static <A> Bridge<A> |
create(Class<A> type,
String... ignoredProperties)
Shortcut method used to create a Bridge.
|
static <A> Bridge<A> |
create(Connection connection,
Class<A> type,
String... ignoredProperties)
Shortcut method used to create a Bridge.
|
void |
delete(A item)
Deletes the specified item from the database.
|
Connection |
getConnection()
Gets the actual bridge connection.
|
protected SqlDescriptor |
getDescriptor() |
Set<String> |
getIgnoredProperties() |
protected String |
getSelectQuery() |
Class<A> |
getType()
Gets the type bridged by the current object.
|
void |
insert(A item)
Insert the specified item in the database.
|
Query<A> |
newQuery() |
<I extends A> |
newQuery(Class<I> desiredType) |
void |
setConnection(Connection connection)
Deprecated.
This method cannot be used anymore and does nothing. Use the
singleton instance from the Connector class instead.
|
void |
update(A item)
Updates the specified item in the database.
|
public Bridge(Class<A> type, String... ignoredProperties) throws SQLException
type - The type of the class to be bridged.SQLExceptionConnectionManagerpublic Bridge(Connection connection, Class<A> type, String... ignoredProperties) throws SQLException
connection - The connection to the database.type - The type of the class to be bridged.SQLExceptionConnectionManagerpublic static <A> Bridge<A> create(Class<A> type, String... ignoredProperties) throws SQLException
A - The type of the corresponding object to create. Automatically
inferred from the type parameter.type - The type of the class to be bridged.SQLExceptionpublic static <A> Bridge<A> create(Connection connection, Class<A> type, String... ignoredProperties) throws SQLException
A - The type of the corresponding object to create. Automatically
inferred from the type parameter.connection - The connection to the database.type - The type of the class to be bridged.SQLExceptionpublic Class<A> getType()
protected SqlDescriptor getDescriptor()
public Set<String> getIgnoredProperties()
protected String getSelectQuery()
public Connection getConnection()
public void setConnection(Connection connection)
connection - The connection to use to get data.public void insert(A item) throws SQLException
item - The item to insert.SQLException - if a problem occurs during database operations.public void update(A item) throws SQLException
item - The item to update.SQLException - if a problem occurs during database operations.public void delete(A item) throws SQLException
item - The item to delete.SQLException - if a problem occurs during database operations.Copyright © 2013. All rights reserved.