Netbeans 7.4:从Java db嵌入式数据库创建实体类(JPA) [英] Netbeans 7.4: Creating entity classes (JPA) from java db embedded database

查看:158
本文介绍了Netbeans 7.4:从Java db嵌入式数据库创建实体类(JPA)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Netbeans 7.4来构建我的应用程序.而且,我正在使用嵌入式Java db.现在,我想从数据库中的数据库中生成JPA实体.

I am using Netbeans 7.4 to build my application. And also, I am using embedded java db. Now, I want to generate my JPA entities from my database from my database.

但是,当我 rightclick my package -> New -> Entity classes from database,选择我的数据库,Available Tables甚至没有显示ANK模式中的单个表.

But, when I rightclick my package -> New -> Entity classes from database, select my database, Available Tables is not showing up even a single one of the tables inside ANK schema.

我注意到的另一件奇怪的事情是,当我从Netbeans服务选项卡连接数据库时,会出现两个模式选项.首先,加粗的APP,第二个Other schemas.架构APP没有任何表.这些表位于Other schemas中的ANK模式中.

One more strange thing I noticed is when I connect my db from Netbeans services tab, two schema options appear. First, APP in bold, second Other schemas. Schema APP don't have any tables. The tables are in ANK schema in Other schemas.

有人可以告诉我我哪里出问题了吗?

Can anybody tell me where I could have gone wrong?

我什至不知道我是否应该使用java db,还是应该去吸引人的h2,HSQL或某些成熟的db,例如mysql.

I don't even know if I should be using java db, or I should go for pretty appealing h2, HSQL or some matured db like mysql.

推荐答案

与Derby的Nebeans接口有些棘手.

The Nebeans interface to Derby is a bit tricky.

  • 在创建新数据库时,默认情况下仅创建APP模式(SYS *模式除外).

  • When creating a new database, only the APP schema is created by default (except for the SYS* schemas).

在不指定用户名的情况下连接到数据库时,默认架构将变为APP

When you connect to the database without specifying a username, your default schema becomes APP

以john用户身份进行连接时,默认架构将变为john,但是直到在其中创建SQL对象之前,才会创建架构john.

When connecting as user john, your default schema becomes john, BUT the schema john is NOT created, until you create an SQL object in it.

这意味着,如果您以john用户的身份在Netbeans中创建到Derby的初始连接,则无法在下拉菜单中选择john作为连接的架构,因为尚未创建.如果您随后选择另一个模式,请创建表,断开连接,然后创建另一个连接,您将能够选择john作为您的模式,并且您将找到使用前一个连接创建的表.

This means that if you create an initial connection to Derby in Netbeans as user john, you cannot choose john as the schema for the connection in the pull-down menu, because it has not been created yet. If you then choose another schema, create your table, disconnect and then create another connection you will be able to choose john as your schema, and you will find the table you created with the previous connection.

即使您在下拉菜单中为第一个连接选择了不同的架构,在开始执行create table语句之前,也会创建一个与您连接的用户名同名的架构,并将其设置为默认架构.

Even though you chose a different schema in the pull-down menu for the first connection, a schema with the same name as the username you connect as is created and set as default before starting to execute the create table statement.

这篇关于Netbeans 7.4:从Java db嵌入式数据库创建实体类(JPA)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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