Smell in ILikeExpression
by Mike Slattery
I ran across a minor code smell in Hibernate when dealing with
case-insensitive like. The offending class is ILikeExpression:
if ( dialect instanceof PostgreSQLDialect ) {
return columns[0] + " ilike ?";
}
else {
return dialect.getLowercaseFunction() + '(' + columns[0] + ") like
?";
}
This might be better and more OO:
String ilikeOperator = dialect.getILikeOperator();
if ( ilikeOperator != null ) {
return columns[0] + " " + ilikeOperator + " ?";
}
else if ( dialect.areStringComparisonsCaseInsensitive() ) {
return columns[0] + " like ?";
}
else {
return dialect.getLowercaseFunction() + '(' + columns[0] + ") like
?";
}
PostgresSQLDialect.getILikeOperator() would return "ilike". All other
dialects would return null.
17 years, 8 months
dynamic entities
by Iyad Elian
Hi hibernate-dev,
I have an interest in modifying hibernate core to support an
alternative persistence model common in some domains like the medical
domain. how do I go about it?
here is a small description of the problem and a solution:
problem:
Objects map one to one to tables as specified at design time which is
normally what most applications require. Object relational mapping
runtimes like hibernate core cater well for this common case. However,
some applications require a catalog of entities and their attributes.
Other applications require a more dynamic mapping to a set of few
fixed tables regardless of the number of domain objects.
solution:
Persist entities to an EAVCR meta-model which stores values of
attributes in a generic Data table. The values can only be stored as a
generic type (String) but types can be tightened at runtime. This also
means that all dynamic entities, heterogeneous as they maybe, are
stored in one table and cataloged by a few more. Using such model
complicates the native SQL to access the data so it maybe necessary to
map the SQL to hide such complexity. Fortunately, domains using this
model require entity centric queries (load all data for a patient)
which is more coarse grained.
does this sound interesting to anyone on this list?
Thanks.
--Iyad
---------------------------------
Ahhh...imagining that irresistible "new car" smell?
Check outnew cars at Yahoo! Autos.
17 years, 8 months