From: Joshua D. <pg...@ya...> - 2004-06-30 11:24:46
|
See my comments below. (Please remember that I'm the FNG around here so my comments might be dumb ;->). > -----Original Message----- > From: hib...@li... > [mailto:hib...@li...] On > Behalf Of Aaron Knauf > Sent: Tuesday, June 29, 2004 6:24 PM > Subject: RE: Re[2]: [Hibernate] Check named queries [snip] > I suggest that named query validation be done by the > Dialect implementation, rather than by checking against a live DB. Why the dialect? It doesn't know about the schema, does it? It seems that Hibernate (by design) uses the database itself to check the generated SQL versus the db schema in a 'late binding' manner. Users (myself included) may expect this, so I would think that any query validation would need to be optional or elective at least. In any case, it is true that the database will always check the SQL it recieves for compatibility with the schema anyway, so maybe this query validation would simply provide better error messages? If so, that sounds to me like a 'nice to have' rather than a 'must have'. (remember: FNG here) > Here's why: > > IMHO checking HQL queries to see that they will run against a > specific DB breaks an abstraction. My viewpoint is that the > hibernate mapping docs define two things: > > 1) The class model that your application persists. > 2) A mapping of that class model to a RDBMS schema. > > HQL queries are not intended to be run against the RDBMS > schema. They are intended to run against the class model. > Whether or not a given RDBMS is capable of supporting the > defined mappings and queries is not really relevant to the > correctness of the queries. It should be possible to test > the correctness of the mappings/queries independently of the database. > > Compiling the mapping files (including the named HQL queries) > will (should) test this. Agreed, and this seems more in line with the design of Hibernate. [snip] > From there, it becomes obvious that the only thing that we > /need/ to check against a live database is whether or not the > RDBMS schema specified in our mapping docs matches that > installed in the database instance to which we are connected. [snip] Just a thought: A mapping->schema check could be something that the user could enable or disable in the Hibernate configuration, or as a separate tool. Come to think of it, doesn't the 'auto ddl' option already do this in some way? |