You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by "KARR, DAVID" <dk...@att.com> on 2017/01/13 23:57:26 UTC
Any way to define custom properties in a datasource definition that
can be read by the application?
My problem may just be a SQL issue, but let me describe the whole problem.
I've written a small back-end service that runs an Oracle query (using Spring JDBC). I built it first with a particular datasource in mind, but I knew I would be changing to another datasource, and also to make it use multiple similarly-formatted datasources. I was told that they would all have the same schema, so I wasn't that concerned (dumb).
Using the original datasource, I could run a query like "select variouscolumns from TABLE_NAME ...". I'm now about to integrate the second datasource, but in this datasource, I have to do "select variouscolumns from BLAH.TABLE_NAME ..." (what is the Oracle SQL term for what "BLAH" represents?).
I have to design a strategy will let me use basically the same query on both datasources (and others). The best idea I can come up with is defining environment strings associated with each datasource that represents the "table prefix" (still don't know what that term is). This can work, but it's a little annoying. Is there some way I could define a custom property in each datasource Resource defined in "tomee.xml" and have that readable by the application?
Re: Any way to define custom properties in a datasource definition
that can be read by the application?
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi
I would recommand you to not touch too much datasources but you can create
a DataSourceConfig as resource and inject the properties you want. If you
don't want a custom type (DataSourceConfig) use:
<Resource id="config" class-name="org.apache.openejb.config.sys.MapFactory"
factory-name="create">
....properties....
</Resource>
and @Resource(name="config") Properties props;
Side note: properties are synchronized so maybe wrap it in a plain HashMap
for runtime perf (use @PostConstruct).
Le 14 janv. 2017 00:57, "KARR, DAVID" <dk...@att.com> a écrit :
My problem may just be a SQL issue, but let me describe the whole problem.
I've written a small back-end service that runs an Oracle query (using
Spring JDBC). I built it first with a particular datasource in mind, but I
knew I would be changing to another datasource, and also to make it use
multiple similarly-formatted datasources. I was told that they would all
have the same schema, so I wasn't that concerned (dumb).
Using the original datasource, I could run a query like "select
variouscolumns from TABLE_NAME ...". I'm now about to integrate the second
datasource, but in this datasource, I have to do "select variouscolumns
from BLAH.TABLE_NAME ..." (what is the Oracle SQL term for what "BLAH"
represents?).
I have to design a strategy will let me use basically the same query on
both datasources (and others). The best idea I can come up with is
defining environment strings associated with each datasource that
represents the "table prefix" (still don't know what that term is). This
can work, but it's a little annoying. Is there some way I could define a
custom property in each datasource Resource defined in "tomee.xml" and have
that readable by the application?