Hibernate automatically creates a database table. Instead of creating a login user space, it creates a System space.

Source: Internet
Author: User
Hibernate automatically creates a database table. Instead of creating a login user space, it creates a System space.

Hibernate automatically creates a database table. Instead of creating a login user space, it creates a System space.

Problem description: Hibernate automatically creates a database table. Instead of creating a login user space, it creates a System space.

Logon User: penw

Recently, in phase II of the project, the database needs to be transferred from Mysql to Oracle. Therefore, the entity class needs to be restructured to implement hibernate's automatic table creation function.

For example, users, roles, permissions, and intermediate tables between them:

@ ManyToMany (targetEntity = Power. class, cascade = {CascadeType. PERSIST,
CascadeType. MERGE })
@ JoinTable (name = "ACC_ROLE_POWER", joinColumns ={@ JoinColumn (name = "role_id")}, inverseJoinColumns ={@ JoinColumn (name = "power_id ")}, uniqueConstraints = @ UniqueConstraint (columnNames = {
"Role_id", "power_id "}))

The entity class has been compiled, but when I started the server, I found that all the tables ran to the System user tablespace, instead of the User table I specified. After checking, it is found that Oracle and Mysql are different. You need to add schema = "penw" in the annotation to specify the space. Therefore, the problem can be solved successfully after the annotation is added.

The Code is as follows:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.