java - how to get column metadata in mybatis -
i need list of columns in table using mybatis/ibatis in java 1.5.
that's not typical requirement (99.99% of applications using ibatis or whatever orm knows db schema). ibatis sql mapper, must write sql query yourself. , there no standard sql query (afaik) gives number of columns in table.
i can suggest 2 approaches:
make sql query selecting catalog tables. that's normal way of knowing db metadata. depends on particular database engine. , it's not related ibatis.
quick , dirty: make ad-hoc query
select * mytable limit 1
(replace limit db analog), map in ibatis through hashmap, , in dao count number of keys.
Comments
Post a Comment