db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Mahler <t...@apache.org>
Subject Re: SQL Generation
Date Sat, 30 Nov 2002 16:10:23 GMT
Hi Tim

O'brien, Tim wrote:
> I'm trying to get OJB working with SQL, and I ran into a what I'd
> consider a small bug. (Although, I will admit the problem may be my own
> studipity.) I'll be talking in PostgreSQL, but I'd imagine that this
> problem could popup in a number of databases.
> 
> Assume for a moment that someone wants to create a table to model
> Timezone,
> 
> 	-- Table: timezone
> 	CREATE TABLE "timezone" (
>   		"timezone_id" int4 NOT NULL, 
>   		"offset" float8 NOT NULL, 
>   		"region" varchar(128) NOT NULL, 
>   		CONSTRAINT "PK_timezone_id" PRIMARY KEY ("timezone_id")
> 	); 
> 
> And, using P6SPY to look at a SQL statement that OJB generates we get:
> 
> 	"SELECT A0.region,A0.offset,A0.timezone_id FROM timezone A0"
> 
> PostgreSQL will choke on "offset" because it is a keyword....
> 

You have to tell OJB to use the quoted name in repository.xml too!

> There are two solutions to this problem:
> 
> 1. Tell people not to use keywords as column or table names.

Most DB vendors give this advice. This is not OJB specific.

> 2. Surround all column and table names with double quotes.

OJB relies on the information you provide in repository.xml, so you have 
  full control...

cheers,
Thomas

> 
> --------
> Tim O'Brien 
> Transolutions, Inc.
> 18 N Waukegan Road
> Lake Bluff, Il 60044
> W 847-574-2143
> F 847-234-3471
> M 847-863-7045
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:ojb-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ojb-dev-help@jakarta.apache.org>
> 
> 
> 
> 



Mime
View raw message