Hibernate configuration file (.cfg.xml) for mapping multiple MySQL tables in the same database?

后端 未结 2 461
轮回少年
轮回少年 2021-01-18 13:43

I am experimenting with Hibernate for my Java web app. The following is part of my hibernate.cfg.xml, and I wondering how to map multiple database tables in the same configu

2条回答
  •  甜味超标
    2021-01-18 14:27

    We should not specify mappings in cfg.xml file. It has to be done by either annotations or XML. For Annotations: The cfg.xml file that is provided by you looks ok, if we are using the annotations to indicate database mappings with entity classes.

    To use XML way of mapping between Entities and Tables, an hbm.xml file needs to be created and in that case, Replace

    
    

    with something like

    
            
                
                
            
            
                
            
        //all the database mappings
    
    

    Sorry, if I understand your question wrongly.

提交回复
热议问题