db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Monroe" <Greg.Mon...@DukeCE.com>
Subject RE: referencing foreign keys in other packages
Date Fri, 30 Sep 2005 14:18:24 GMT
AFAIK, the beans are just repackaging of the normal Torque table 
classes.  Since the base classes are all public, there should
not be a security problem if the create<Bean> methods are public.

Why don't you submit your template modes via a Scarab enhancement
request?

IMHO, unless you are running a secured class loader, the method
modifiers are just there to warn other developers that "there 
be dragons here".. if you want to use it.  Not a big problem if 
you have access to the source code or the docs spells out the 
"contract" properly. But it can sometimes lead to major headaches 
otherwise.

As to referring to other db packages, I noticed that the code
Database class in the OM has a package attribute that is setable
via a package="...." attribute.  I'm not enough of a template
guru to say for sure, but it seems like there should be a way 
get the list of databases being generated and run thru them to 
automatically create a set of imports.  This would replace the
need for the ant replace task. 

Hmm, maybe you could do it by adding with something like the
following to the appropriate templates:

#set $currentPackage = $table.Database.Package
#foreach ($col in $table.Columns)
    #if($col.isForeignKey())
        #if  $col.Table.Database.Package != $currentPackage )
            import ${col.Table.Database.Package}.${col.BaseClass};
	  #end
    #end
#end

Good luck.

Greg


> -----Original Message-----
> From: Robert Dietrick 
> 
> My Torque schema definition specifies tables with foreign keys which 
> span Java packages, and I have Bean generation turned on.  By 
> default, 
> this causes Torque to generate Java code which doesn't 
> compile due to a 
> number of issues:
> 
> 1. In each bean class with a foreign key constraint that 
> spans packages, 
> the generated import statements for the Bean classes in the foreign 
> package are assumed to be in the local package, and therefore 
> reference 
> non-existent classes.
> 2. Classes with cross-package foreign keys attempt to call 
> the methods 
> create[ClassName]([BeanClassName]) and getBean(IdentityMap) 
> (which have 
> default package-level access) from a different package.
> 
> I'm getting around issue #1 by way of an ant <replace> task 
> which fixes 
> the code.
> 
> For issue #2, I've modified the template files that the 
> generator uses 
> to make the methods create${table.JavaName}(${beanClassName}) and 
> getBean(IdentityMap) public.  I'm just wondering if anyone forsees a 
> real security concern with this change?
> 
> 
> -- 
> Robert Dietrick
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 

Duke CE Privacy Statement
Please be advised that this e-mail and any files transmitted with it are confidential communication
or may otherwise be privileged or confidential and are intended solely for the individual
or entity to whom they are addressed.  If you are not the intended recipient you may not rely
on the contents of this email or any attachments, and we ask that you  please not read, copy
or retransmit this communication, but reply to the sender and destroy the email, its contents,
and all copies thereof immediately.  Any unauthorized dissemination, distribution or copying
of this communication is strictly prohibited.



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message