java - hibernate forward engineering generates one-to-many relationship model without error, but only one table is generated
我想大声告诉你
我想大声告诉你 2017-05-17 10:04:01
0
1
503

I am now going to do forward engineering, the one-to-many relationship between User customers and Order orders

The following are their entity classes

package com.cw.entity; import java.util.Set; public class User implements java.io.Serializable { private Integer id; private String username; private String password; private Set order; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public Set getOrder() { return order; } public void setOrder(Set order) { this.order = order; } public User(String username, String password, Set order) { super(); this.username = username; this.password = password; this.order = order; } } package com.cw.entity; public class Order implements java.io.Serializable { private Integer id; private User user; private String shop; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public User getUser() { return user; } public void setUser(User user) { this.user = user; } public String getShop() { return shop; } public void setShop(String shop) { this.shop = shop; } public Order(User user, String shop) { super(); this.user = user; this.shop = shop; } }

The following is the hbm.xml configuration file

                                    

I have checked other configurations and there is no problem, hibernate.cfg.xml is also fine (two entity model configuration items and hbm2ddl configuration have been added), but execution

package com.cw.entity; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; import org.hibernate.classic.Session; import org.hibernate.id.Configurable; public class Test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Configuration configure = new Configuration().configure(); SessionFactory buildSessionFactory = configure.buildSessionFactory(); Session session = buildSessionFactory.openSession(); Transaction tx = session.beginTransaction(); tx.commit(); } }

After that, only the user table was generated, but the order table was not generated. What is the problem now?

我想大声告诉你
我想大声告诉你

reply all (1)
过去多啦不再A梦

Use annotations, annotations are popular now

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!