java - How do I depend on hibernate annotated mappings from a separate project? -


I am trying to figure out how to mapping the two separate projects that share some organizations . Since they only share a limited subset of mapping, so my first thought was to separate these mappings into a separate jar. I am using hibernate annotations to mapping (so they are in class files, not separate XML).

Both Project A and Project depend on this mapping project, in which only some hibernate mapping project A does not have any mapping, but the project B does whatever I do always have problems The reason seems to be because I do not configure a fixed unit for the mapping project, the mapping is never taken in the same way for Project B. If I configure a firm unit in the Mappings project, Project A works, but when I run a query in Project B, I ( mapping is the name of the class) gives:

  java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: mapping is not a map  

I believe this project is due to B due to its persistence The unit, and obviously, is not being merged. I really do not want them either, I would like to configure only one in Project A / B, and they do not rely on jars. So is there a way to hibernate to scan and map annotation in a dependency jar and add it to the current firmness unit?

I do not know whether you use spring or not but I use spring's abilities To get this behavior between mapping space property using packagesToScan property is as follows

   

I hope this can be useful

UPDATE

According to the JPA specification

A group of managed hardness classes that are firmly managed by the unit have been defined using one or more of the following:

  • A clear list of classes
  • Annotated managed persistence classes

  < / Li>    & lt; Persistence & gt; & Lt; Persistent-entity name = "Titan" & gt; & Lt ;! - Clarity list of classes - & gt; & Lt; Classes & gt; Br.com.ar.model.domain.A & lt; / Square & gt; & Lt; Classes & gt; Br.com.ar.model.domain.B & lt; / Square & gt; & Lt ;! - Set any jar file using jar-file element - & gt; & Lt ;! - Its value is the relative path of the JAR file, in which persistence.xml - & gt; & Lt; Jar file & gt; ../ lib / customer.jar & lt; / Jar file & gt; & Lt ;! - ORM mapping file - & gt; & Lt ;! - This class may be present anywhere on the path - & gt; & Lt; Mapping file & gt; Mapping.xml & lt; / Mapping file & gt; & Lt; Properties & gt; Properties goes here & lt; / Properties & gt; & Lt; / Persistence unit & gt; & Lt; / Persistence>  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -