You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Andy Law <an...@roslin.ed.ac.uk> on 2010/01/25 10:58:00 UTC

How would you - the experts - design this?

We have built an application using iBatis to act as the interface between
code and database (no, really :o}). As you would expect with such a
magnificent tool, it works well.

We have a different application that we are starting to ramp up. It uses the
same data model for the most part with the same mappings from schema to
model. In fact, it actually uses the same database instance -  the datasets
for each application are overlapping.

I'd like to maintain a single copy of the code with a single set of SQLMaps
where possible but be able to generate a jar file that will pull out some of
the data with extra "where xyz = 'abc'" type constraints. What is the best
way of doing this in your experience?

To flesh out what I have described so poorly above, imagine that I have data
from "populations" A, B and C. Application 1 needs to see data from A and B.
Application 2 needs to see data from B and C. There is a "roles" table and a
"populations_to_roles" table doing the many_to_many stuff and I'd like to be
able to do all this from a single jar. FWIW, we're using maven as our build
and management tool.

Our objects are extracted via DAOs, which come from a singleton DAOFactory.
My current thoughts are along the lines of injecting attributes into the
DAOFactory that are then subsequently dumped into the DAOs that it
generates.

Thanks in advance for any help, ideas or discussion points that you can
provide.


Later,

Andy

-- 
View this message in context: http://old.nabble.com/How-would-you---the-experts---design-this--tp27304322p27304322.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


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


Re: How would you - the experts - design this?

Posted by Andy Law <an...@roslin.ed.ac.uk>.
Nathan,


nmaves wrote:
> 
> From what I can gather from this chain I would say what you are looking
> for can be found by using maven2 and modules.
> 
> I use this all the time with the following kind of setup
> 
> /parent module
>   /core module (this has all of the common sqlmap etc...)
>   /db-access-scope1 module (depends on core)
>   /db-access-scope2 module (depends on core)
> 
> Check it out it might just be what you are looking for
> 
> 

The db-access module is itself already a module within a multi-module maven
build so we're comfortable with that and it's been on our list of options
from the outset. I'm wondering what parts you would factor out into the
scope1/scope2 modules though?

The ideas that we've kicked around here over the past day or two tended to
drift back to a specific implementation of the DAOFactory in each sub-module
that has embedded the "magic strings" that the dynamic SQL might use. Is
that the kind of thing that you were thinking of?

Later,

Andy
-- 
View this message in context: http://old.nabble.com/How-would-you---the-experts---design-this--tp27304322p27325937.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


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


Re: How would you - the experts - design this?

Posted by Nathan Maves <na...@gmail.com>.
From what I can gather from this chain I would say what you are looking for can be found by using maven2 and modules.

I use this all the time with the following kind of setup

/parent module
  /core module (this has all of the common sqlmap etc...)
  /db-access-scope1 module (depends on core)
  /db-access-scope2 module (depends on core)

Check it out it might just be what you are looking for

Nathan


On Jan 26, 2010, at 2:26 AM, Andy Law wrote:

> 
> Rick,
> 
> Thanks for that response.
> 
> 
> Rick.Wellman wrote:
>> 
>> I am not even sure this is worth two-cents but:
>> What (for lack of a better word) confuses me is the phrase "generate a
>> jar file that will pull out some of the data..."
>> 
> 
> What I'm trying to say is that in the ideal world, application 1 would have
> a dependency on a specific jar (let's call it db-access-scope1) and
> application 2 would have a similar dependency on a different jar (let's call
> that one db-access-scope2). The two jars (db-access-scope{1,2}) would be
> generated from a single common code base but with subtley different
> configurations.
> 
> 
> 
> Rick.Wellman wrote:
>> 
>> From what I can decipher, I would handle it like this.  As you say, your
>> data model itself is identical but the second application needs extra
>> constraints.  I would simply use iBatis' dynamic SQL features to write
>> the additional constraints into your sqlmaps.  Only your second
>> application would "trigger" the additional constraints.  I would imagine
>> that you would somehow encapsulate this into some class (or classes)
>> that the second application uses and the first does not.  While I could
>> have missed something, it just seems like you might be looking for a
>> solution that is more complicated than it needs to be.
>> 
> 
> I think that we may end up with a variation of this post-compilation
> configuration. The niggle that I have is the potential to misconfigure, but
> I think that with sufficient counselling I may be able to get over that :o}
> 
> Thanks again.
> 
> Later,
> 
> Andy
> 
> -- 
> View this message in context: http://old.nabble.com/How-would-you---the-experts---design-this--tp27304322p27319887.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
> 

Nathan Maves
nathan.maves@gmail.com




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


RE: How would you - the experts - design this?

Posted by Andy Law <an...@roslin.ed.ac.uk>.
Rick,

Thanks for that response.


Rick.Wellman wrote:
> 
> I am not even sure this is worth two-cents but:
> What (for lack of a better word) confuses me is the phrase "generate a
> jar file that will pull out some of the data..."
> 

What I'm trying to say is that in the ideal world, application 1 would have
a dependency on a specific jar (let's call it db-access-scope1) and
application 2 would have a similar dependency on a different jar (let's call
that one db-access-scope2). The two jars (db-access-scope{1,2}) would be
generated from a single common code base but with subtley different
configurations.



Rick.Wellman wrote:
> 
> From what I can decipher, I would handle it like this.  As you say, your
> data model itself is identical but the second application needs extra
> constraints.  I would simply use iBatis' dynamic SQL features to write
> the additional constraints into your sqlmaps.  Only your second
> application would "trigger" the additional constraints.  I would imagine
> that you would somehow encapsulate this into some class (or classes)
> that the second application uses and the first does not.  While I could
> have missed something, it just seems like you might be looking for a
> solution that is more complicated than it needs to be.
> 

I think that we may end up with a variation of this post-compilation
configuration. The niggle that I have is the potential to misconfigure, but
I think that with sufficient counselling I may be able to get over that :o}

Thanks again.

Later,

Andy

-- 
View this message in context: http://old.nabble.com/How-would-you---the-experts---design-this--tp27304322p27319887.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


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


RE: How would you - the experts - design this?

Posted by "Rick.Wellman" <Ri...@kiewit.com>.
I am not even sure this is worth two-cents but:
What (for lack of a better word) confuses me is the phrase "generate a
jar file that will pull out some of the data..."

>From what I can decipher, I would handle it like this.  As you say, your
data model itself is identical but the second application needs extra
constraints.  I would simply use iBatis' dynamic SQL features to write
the additional constraints into your sqlmaps.  Only your second
application would "trigger" the additional constraints.  I would imagine
that you would somehow encapsulate this into some class (or classes)
that the second application uses and the first does not.  While I could
have missed something, it just seems like you might be looking for a
solution that is more complicated than it needs to be.

Hope that makes sense and either gives you a solution or a solution to
avoid ;-)

-----Original Message-----
From: Andy Law [mailto:andy.law@roslin.ed.ac.uk] 
Sent: Monday, January 25, 2010 3:58 AM
To: user-java@ibatis.apache.org
Subject: How would you - the experts - design this?


We have built an application using iBatis to act as the interface
between
code and database (no, really :o}). As you would expect with such a
magnificent tool, it works well.

We have a different application that we are starting to ramp up. It uses
the
same data model for the most part with the same mappings from schema to
model. In fact, it actually uses the same database instance -  the
datasets
for each application are overlapping.

I'd like to maintain a single copy of the code with a single set of
SQLMaps
where possible but be able to generate a jar file that will pull out
some of
the data with extra "where xyz = 'abc'" type constraints. What is the
best
way of doing this in your experience?

To flesh out what I have described so poorly above, imagine that I have
data
from "populations" A, B and C. Application 1 needs to see data from A
and B.
Application 2 needs to see data from B and C. There is a "roles" table
and a
"populations_to_roles" table doing the many_to_many stuff and I'd like
to be
able to do all this from a single jar. FWIW, we're using maven as our
build
and management tool.

Our objects are extracted via DAOs, which come from a singleton
DAOFactory.
My current thoughts are along the lines of injecting attributes into the
DAOFactory that are then subsequently dumped into the DAOs that it
generates.

Thanks in advance for any help, ideas or discussion points that you can
provide.


Later,

Andy

-- 
View this message in context:
http://old.nabble.com/How-would-you---the-experts---design-this--tp27304
322p27304322.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


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


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