使用休眠获取数据库元数据 [英] get database metadata using hibernate

查看:416
本文介绍了使用休眠获取数据库元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从表中获取列名称,我在此引用了此链接: http://www.kodejava.org/examples/163.html

I need to get column names from a table, I referred this link here: http://www.kodejava.org/examples/163.html

它显示使用jdbc获取元数据,我想知道是否有任何与此类似的休眠方法?我将mysql和oracle作为数据库.

It shows using jdbc to get the metadata, I want to know is there any hibernate method similar to this? I am having mysql and oracle as the databases.

推荐答案

您可以使用以下代码:

String[] columnNames = sessionFactory.getClassMetadata(Java.class).getPropertyNames();

Type[] columnTypes = sessionFactory().getClassMetadata(Java.class).getPropertyTypes();

这篇关于使用休眠获取数据库元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆