kyters / jlibs

Automatically exported from code.google.com/p/jlibs
1 stars 0 forks source link

Quote database identifiers #16

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When table/column names contain values that need to be quoted, it can be 
awkward to use the jlibs annotations.

For example, writing @table(name="\"foo\"") is inconvenient and hard-codes the 
use of double quotes.

It would be better to use DatabaseMetaData.getIdentifierQuoteString() to 
determine how to perform the quoting, but that's not generally going to be 
available at the time the annotations are being written or processed.  It would 
be best to apply the database-specific quoting for the JDBC connection at the 
time the identifiers are being used.

It would probably be appropriate to make this behavior optional and to allow 
the user to explicitly set a quoting string; but I think it would be reasonable 
to have it enabled by default -- it would only impact code that already 
contains explicit identifier escaping.

Original issue reported on code.google.com by eire...@gmail.com on 22 May 2011 at 10:08

GoogleCodeExporter commented 9 years ago
FIXED@r1525

some in compatible api change done:

JDBC jdbc = new JDBC(DATA_SOURCE);
EMPLOYEES = (EmployeeDAO) DAO.create(Employee.class, jdbc);
DEPARTMENTS = (DepartmentDAO) DAO.create(Department.class, jdbc);

the second argument to DAO.create(...) was DataSource, now it is JDBC
i.e you create single JDBC instance and use it for all DAO's. earlier 
each DAO had its own JDBC instance.

now all table and columnnames are quoted using 
DatabaseMetaData.getIdentifierQuoteString();

to turn off quoting use:
    JDBC jdbc = new JDBC(DATA_SOURCE, null); // second arg is quoteString

to explicitly set quoteString:
   JDBC jdbc = new JDBC(DATA_SOURCE, myQuoteString);

Original comment by santhosh.tekuri@gmail.com on 5 Jun 2011 at 7:34