working with raw mapk,vs instead of entities?

2009-12-17 Thread Kristian Rink

Folks;

not sure whether this is a stupid question; I've been playing with this 
idea before already: As far as I see, after dealing with a bunch of 
other approaches (EclipseLink/JPA, hibernate, ...), I saw that in the 
end parts of our backend code ended up being a weak re-implementation 
of the iBatis idea, which makes me reconsider iBatis once again. For 
now, looking at the feature set, there is one thing I would want to do 
with iBatis, but I am not sure how to do so / whether it can be done at all:


In my situation, I select * from a bunch of tables joined via an 
identifier, to, by then, take the identifier and a few other fixed 
columns which will appear all the time and put them into designated 
values of an entity, and the rest of the selection simply goes to a 
Mapstring,string inside the entity. While this works pretty well, say, 
inside a Spring JdbcTemplate mapper, I am unsure how / if to do 
something like this in an iBatis configuration file as well. So to ask:


- Is it possible?
- How to do it, if so?

Thanks a bunch in advance and kindest regards,
Kristian

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



Re: working with raw mapk,vs instead of entities?

2009-12-17 Thread Larry Meadors
Interesting idea - so you end up with something like this?

myEntity.id
myEntity.name
myEntity.attributes.someField
myEntity.attributes.someOtherField

You could do that, but since you're doing select * you'd have to do
it with a result map or row handler.

Larry


On Thu, Dec 17, 2009 at 1:32 AM, Kristian Rink li...@zimmer428.net wrote:
 Folks;

 not sure whether this is a stupid question; I've been playing with this idea
 before already: As far as I see, after dealing with a bunch of other
 approaches (EclipseLink/JPA, hibernate, ...), I saw that in the end parts of
 our backend code ended up being a weak re-implementation of the iBatis
 idea, which makes me reconsider iBatis once again. For now, looking at the
 feature set, there is one thing I would want to do with iBatis, but I am not
 sure how to do so / whether it can be done at all:

 In my situation, I select * from a bunch of tables joined via an identifier,
 to, by then, take the identifier and a few other fixed columns which will
 appear all the time and put them into designated values of an entity, and
 the rest of the selection simply goes to a Mapstring,string inside the
 entity. While this works pretty well, say, inside a Spring JdbcTemplate
 mapper, I am unsure how / if to do something like this in an iBatis
 configuration file as well. So to ask:

 - Is it possible?
 - How to do it, if so?

 Thanks a bunch in advance and kindest regards,
 Kristian

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



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



Re: working with raw mapk,vs instead of entities?

2009-12-17 Thread Kristian Rink

Larry Meadors schrieb:

Interesting idea - so you end up with something like this?

myEntity.id
myEntity.name
myEntity.attributes.someField
myEntity.attributes.someOtherField


Yes, that's basically what it is supposed to be. Reason for this: We're, 
in the backend, using a legacy (proprietary :( ) document management 
system which has a somewhat dynamic RDBMS database / table structure 
which is subject to extension pretty often, so, asides a couple of 
fixed values (id, name, ...), the dynamic approach of having 
everything else in a Map or a Properties object so far has proven to be 
the most straightforward solution.




You could do that, but since you're doing select * you'd have to do
it with a result map or row handler.


Hmmm... is there a preferred way among these both and/or quick howtos? 
I already stumbled across the RowHandler but, so far, am unsure how to 
correctly apply this one... I'm using iBatis in a Spring 2.x 
environment, btw. :)


TIA and all the best,
Kristian

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



Re: working with raw mapk,vs instead of entities?

2009-12-17 Thread Kristian Rink

Larry Meadors schrieb:

Not really a preferred way - it's going to be up to you to decide if
you want code or configuration.


I see. :)


I think a row handler might be the best option in this case. So you
would have ibatis mapping all of your results to a Map, then in your
RowHandler, you'd take that row, and create the entity object, pluck
out the fixed values, then copy the rest to your entity's attributes
map.


But as far as I investigated things by now, I will still have to, say, 
come up with some sort of mapping configuration telling which column 
(id/name) to be stored in which key/property in java.util.Map? I can't, 
like, in an sqlMap definition, iterate across all the columns found to 
make sure each column gets stored in a Map entry with the same key, like ...


// pseudocode
resultMap id=mapResult class=java.util.HashMap
for column in result.columns
   property name=$column columnName=$column/
/for
/resultMap

... ? This would make this project drastically easier. ;)



You could probably create a RowHandlerEntity sort of solution to do
that in a more general manner which would eliminate some redundant
code.


Yes, that's what comes to mind here. But I'm not half-way there yet I 
guess. :)



Sounds like it'd be a fun project. :)


Indeed. :/ The structure in this system, so far, has successfully kept 
me from applying virtually any kind of available O/R mapping in a 
meaningful way. OTOH however, the iBatis way is pretty straightforward 
and easy-to-explain I guess so not having hibernate in here is not all 
that bad after all. ;)


K.

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