Hibernate problem - “Use of @OneToMany or @ManyToMany targeting an unmapped class”One-to-many relationship Hibernate errorUse of @OneToMany or @ManyToMany targeting an unmapped class:org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: core.user.User.userRole[core.user.UserRole]Hibernate: "Use of @OneToMany targeting an unmapped classAnnotation exception HibernateUse of @OneToMany or @ManyToMany targeting an unmapped class: kg.aladin.jdbc.Student.books[kg.aladin.jdbc.Book]Hibernate map an association as a mapUse of @OneToMany or @ManyToMany targeting an unmapped class microservice architectureHibernate ManyToMany with Join table problems on updateWrong ordering in generated table in jpaDeleting from ManyToMany with IndexColumnConstraint violation in Hibernate unidirectional OneToMany mapping with JoinTable and OrderColumn when removing elementswant to add two different tables(classes) in one hibernate criteriaHibernate Exception: Trying to map a Collection OneToMany without JoinTableHibernate: ManyToMany inverse DeleteMappingJackson2HttpMessageConverter Can not find a (Map) Key deserializer for typeHibernate : Why FetchType.LAZY-annotated collection property eagerly loading?Use of @OneToMany or @ManyToMany targeting an unmapped class:

How should I ask for a "pint" in countries that use metric?

Why is a mixture of two normally distributed variables only bimodal if their means differ by at least two times the common standard deviation?

Is it better in terms of durability to remove card+battery or to connect to charger/computer via USB-C?

Generalized Behrend version for Grothendieck-Lefschetz trace formula

What is a writing material that persists forever or for a long time?

This LM317 diagram doesn't make any sense to me

Quoridor rules when faced the opponent

A sequence that changes sign finally at infinity?

What would +1/+2/+3 items be called in game?

What are the effects of abstaining from eating a certain flavor?

QR codes, do people use them?

Four ships at the ocean with the same distance

Distinguish the explanations of Galadriel's test in LotR

Do injective, yet not bijective, functions have an inverse?

Compressed gas thruster for an orbital launch vehicle?

Reference request: quantifier elimination test

Did depressed people far more accurately estimate how many monsters they killed in a video game?

Password Hashing Security Using Scrypt & Argon2

Writing an ace/aro character?

My previous employer committed a severe violation of the law and is also being sued by me. How do I explain the situation to future employers?

Is it possible to complete a PhD in CS in 3 years?

Write a function

US citizen traveling with Peruvian passport

Did the Ottoman empire suppress the printing press?



Hibernate problem - “Use of @OneToMany or @ManyToMany targeting an unmapped class”


One-to-many relationship Hibernate errorUse of @OneToMany or @ManyToMany targeting an unmapped class:org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: core.user.User.userRole[core.user.UserRole]Hibernate: "Use of @OneToMany targeting an unmapped classAnnotation exception HibernateUse of @OneToMany or @ManyToMany targeting an unmapped class: kg.aladin.jdbc.Student.books[kg.aladin.jdbc.Book]Hibernate map an association as a mapUse of @OneToMany or @ManyToMany targeting an unmapped class microservice architectureHibernate ManyToMany with Join table problems on updateWrong ordering in generated table in jpaDeleting from ManyToMany with IndexColumnConstraint violation in Hibernate unidirectional OneToMany mapping with JoinTable and OrderColumn when removing elementswant to add two different tables(classes) in one hibernate criteriaHibernate Exception: Trying to map a Collection OneToMany without JoinTableHibernate: ManyToMany inverse DeleteMappingJackson2HttpMessageConverter Can not find a (Map) Key deserializer for typeHibernate : Why FetchType.LAZY-annotated collection property eagerly loading?Use of @OneToMany or @ManyToMany targeting an unmapped class:






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








96















I'm finding my feet with Hibernate Annotations and I've hit a problem I hope some one can help with.



I have 2 entities, Section and ScopeTopic. Section has a List class member, so a One to Many relationship. When I run my unit test I am getting this exception:




Use of @OneToMany or @ManyToMany targeting an unmapped class: com.xxx.domain.Section.scopeTopic[com.xxx.domain.ScopeTopic]




I would assume that the error implies that my ScopeTopic entity isn't mapped to a table? I can't see with I have done wrong. Here are the Entity classes:




@Entity
public class Section
private Long id;
private List<ScopeTopic> scopeTopics;

public Section()

@Id
public Long getId()
return id;


public void setId(Long id)
this.id = id;


@OneToMany
@JoinTable(name = "section_scope", joinColumns = @JoinColumn(name="section_id"),
inverseJoinColumns = @JoinColumn(name="scope_topic_id") )
public List<ScopeTopic> getScopeTopic()
return scopeTopic;


public void setScopeTopic(List<ScopeTopic> scopeTopic)
this.scopeTopic = scopeTopic;





@Entity
@Table(name = "scope_topic")
public class ScopeTopic
private Long id;
private String topic;

public ScopeTopic()

@Id
public Long getId()
return id;


public void setId()
this.id = id;


public String getTopic()
return topic;


public void setTopic(String topic)
this.topic = topic;





I'm pretty sure it's my own lack of understanding that's at fault so some guidance would be great, thanks!










share|improve this question






























    96















    I'm finding my feet with Hibernate Annotations and I've hit a problem I hope some one can help with.



    I have 2 entities, Section and ScopeTopic. Section has a List class member, so a One to Many relationship. When I run my unit test I am getting this exception:




    Use of @OneToMany or @ManyToMany targeting an unmapped class: com.xxx.domain.Section.scopeTopic[com.xxx.domain.ScopeTopic]




    I would assume that the error implies that my ScopeTopic entity isn't mapped to a table? I can't see with I have done wrong. Here are the Entity classes:




    @Entity
    public class Section
    private Long id;
    private List<ScopeTopic> scopeTopics;

    public Section()

    @Id
    public Long getId()
    return id;


    public void setId(Long id)
    this.id = id;


    @OneToMany
    @JoinTable(name = "section_scope", joinColumns = @JoinColumn(name="section_id"),
    inverseJoinColumns = @JoinColumn(name="scope_topic_id") )
    public List<ScopeTopic> getScopeTopic()
    return scopeTopic;


    public void setScopeTopic(List<ScopeTopic> scopeTopic)
    this.scopeTopic = scopeTopic;





    @Entity
    @Table(name = "scope_topic")
    public class ScopeTopic
    private Long id;
    private String topic;

    public ScopeTopic()

    @Id
    public Long getId()
    return id;


    public void setId()
    this.id = id;


    public String getTopic()
    return topic;


    public void setTopic(String topic)
    this.topic = topic;





    I'm pretty sure it's my own lack of understanding that's at fault so some guidance would be great, thanks!










    share|improve this question


























      96












      96








      96


      16






      I'm finding my feet with Hibernate Annotations and I've hit a problem I hope some one can help with.



      I have 2 entities, Section and ScopeTopic. Section has a List class member, so a One to Many relationship. When I run my unit test I am getting this exception:




      Use of @OneToMany or @ManyToMany targeting an unmapped class: com.xxx.domain.Section.scopeTopic[com.xxx.domain.ScopeTopic]




      I would assume that the error implies that my ScopeTopic entity isn't mapped to a table? I can't see with I have done wrong. Here are the Entity classes:




      @Entity
      public class Section
      private Long id;
      private List<ScopeTopic> scopeTopics;

      public Section()

      @Id
      public Long getId()
      return id;


      public void setId(Long id)
      this.id = id;


      @OneToMany
      @JoinTable(name = "section_scope", joinColumns = @JoinColumn(name="section_id"),
      inverseJoinColumns = @JoinColumn(name="scope_topic_id") )
      public List<ScopeTopic> getScopeTopic()
      return scopeTopic;


      public void setScopeTopic(List<ScopeTopic> scopeTopic)
      this.scopeTopic = scopeTopic;





      @Entity
      @Table(name = "scope_topic")
      public class ScopeTopic
      private Long id;
      private String topic;

      public ScopeTopic()

      @Id
      public Long getId()
      return id;


      public void setId()
      this.id = id;


      public String getTopic()
      return topic;


      public void setTopic(String topic)
      this.topic = topic;





      I'm pretty sure it's my own lack of understanding that's at fault so some guidance would be great, thanks!










      share|improve this question
















      I'm finding my feet with Hibernate Annotations and I've hit a problem I hope some one can help with.



      I have 2 entities, Section and ScopeTopic. Section has a List class member, so a One to Many relationship. When I run my unit test I am getting this exception:




      Use of @OneToMany or @ManyToMany targeting an unmapped class: com.xxx.domain.Section.scopeTopic[com.xxx.domain.ScopeTopic]




      I would assume that the error implies that my ScopeTopic entity isn't mapped to a table? I can't see with I have done wrong. Here are the Entity classes:




      @Entity
      public class Section
      private Long id;
      private List<ScopeTopic> scopeTopics;

      public Section()

      @Id
      public Long getId()
      return id;


      public void setId(Long id)
      this.id = id;


      @OneToMany
      @JoinTable(name = "section_scope", joinColumns = @JoinColumn(name="section_id"),
      inverseJoinColumns = @JoinColumn(name="scope_topic_id") )
      public List<ScopeTopic> getScopeTopic()
      return scopeTopic;


      public void setScopeTopic(List<ScopeTopic> scopeTopic)
      this.scopeTopic = scopeTopic;





      @Entity
      @Table(name = "scope_topic")
      public class ScopeTopic
      private Long id;
      private String topic;

      public ScopeTopic()

      @Id
      public Long getId()
      return id;


      public void setId()
      this.id = id;


      public String getTopic()
      return topic;


      public void setTopic(String topic)
      this.topic = topic;





      I'm pretty sure it's my own lack of understanding that's at fault so some guidance would be great, thanks!







      hibernate jpa






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 10 '11 at 12:15









      Bozho

      499k112 gold badges971 silver badges1083 bronze badges




      499k112 gold badges971 silver badges1083 bronze badges










      asked Feb 10 '11 at 12:06









      C0deAttackC0deAttack

      16.4k16 gold badges66 silver badges77 bronze badges




      16.4k16 gold badges66 silver badges77 bronze badges






















          6 Answers
          6






          active

          oldest

          votes


















          217














          Your annotations look fine. Here are the things to check:



          • make sure the annotation is javax.persistence.Entity, and not org.hibernate.annotations.Entity. The former makes the entity detectable. The latter is just an addition.


          • if you are manually listing your entities (in persistence.xml, in hibernate.cfg.xml, or when configuring your session factory), then make sure you have also listed the ScopeTopic entity


          • make sure you don't have multiple ScopeTopic classes in different packages, and you've imported the wrong one.






          share|improve this answer


















          • 15





            Ah, thanks! Point 2 was the key, I had forgotten to put ScopeTopic in my annotatedClasses property list when creating the SessionFactory, n00b error!

            – C0deAttack
            Feb 10 '11 at 12:20






          • 5





            Point 1 was the key for me :D thanks

            – PHP Avenger
            Jul 3 '13 at 12:41






          • 3





            For those just hitting this comment. org.hibernate.annotations.Entity is deprecated in Hibernate 4. Point 1 does not apply anymore.

            – gspatel
            Apr 22 '14 at 3:50











          • For me it was point 2, because I kept on editing the hibernate.cfg.xml in my build folder.

            – Torsten
            Oct 20 '15 at 12:14






          • 1





            Thanks to remind me about the persistence.xml

            – Yusuf1494
            Jan 28 '16 at 8:44


















          19














          Your entity may not listed in hibernate configuration file.






          share|improve this answer






























            18














            Mine was not having @Entity on the many side entity



            @Entity // this was commented
            @Table(name = "some_table")
            public class ChildEntity
            @JoinColumn(name = "parent", referencedColumnName = "id")
            @ManyToOne
            private ParentEntity parentEntity;






            share|improve this answer
































              5














              Mostly in Hibernate , need to add the Entity class in hibernate.cfg.xml like-



              <hibernate-configuration>
              <session-factory>

              ....
              <mapping class="xxx.xxx.yourEntityName"/>
              </session-factory>
              </hibernate-configuration>





              share|improve this answer

























              • The syntax is incorrect! how can it be possible start with </...> and close in the same way?

                – elmigue017
                May 13 at 6:32











              • how did you know that .. see it

                – Sai prateek
                May 13 at 16:03


















              0














              I had the same problem and I could solve it by adding the entity into persistence.xml.
              The problem was caused due to the fact that the entity was not added to the persistence config. Edit your persistence file:



              <persistence-unit name="MY_PU" transaction-type="RESOURCE_LOCAL">
              <provider>`enter code here`
              org.hibernate.jpa.HibernatePersistenceProvider
              </provider>
              <class>mypackage.MyEntity</class>


              ...






              share|improve this answer
































                0














                In my case a has to add my classes, when building the SessionFactory, with addAnnotationClass



                Configuration configuration.configure();
                StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
                SessionFactory sessionFactory = configuration
                .addAnnotatedClass(MyEntity1.class)
                .addAnnotatedClass(MyEntity2.class)
                .buildSessionFactory(builder.build());





                share|improve this answer

























                  Your Answer






                  StackExchange.ifUsing("editor", function ()
                  StackExchange.using("externalEditor", function ()
                  StackExchange.using("snippets", function ()
                  StackExchange.snippets.init();
                  );
                  );
                  , "code-snippets");

                  StackExchange.ready(function()
                  var channelOptions =
                  tags: "".split(" "),
                  id: "1"
                  ;
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function()
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled)
                  StackExchange.using("snippets", function()
                  createEditor();
                  );

                  else
                  createEditor();

                  );

                  function createEditor()
                  StackExchange.prepareEditor(
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: true,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: 10,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader:
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  ,
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  );



                  );













                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function ()
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4956855%2fhibernate-problem-use-of-onetomany-or-manytomany-targeting-an-unmapped-clas%23new-answer', 'question_page');

                  );

                  Post as a guest















                  Required, but never shown

























                  6 Answers
                  6






                  active

                  oldest

                  votes








                  6 Answers
                  6






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  217














                  Your annotations look fine. Here are the things to check:



                  • make sure the annotation is javax.persistence.Entity, and not org.hibernate.annotations.Entity. The former makes the entity detectable. The latter is just an addition.


                  • if you are manually listing your entities (in persistence.xml, in hibernate.cfg.xml, or when configuring your session factory), then make sure you have also listed the ScopeTopic entity


                  • make sure you don't have multiple ScopeTopic classes in different packages, and you've imported the wrong one.






                  share|improve this answer


















                  • 15





                    Ah, thanks! Point 2 was the key, I had forgotten to put ScopeTopic in my annotatedClasses property list when creating the SessionFactory, n00b error!

                    – C0deAttack
                    Feb 10 '11 at 12:20






                  • 5





                    Point 1 was the key for me :D thanks

                    – PHP Avenger
                    Jul 3 '13 at 12:41






                  • 3





                    For those just hitting this comment. org.hibernate.annotations.Entity is deprecated in Hibernate 4. Point 1 does not apply anymore.

                    – gspatel
                    Apr 22 '14 at 3:50











                  • For me it was point 2, because I kept on editing the hibernate.cfg.xml in my build folder.

                    – Torsten
                    Oct 20 '15 at 12:14






                  • 1





                    Thanks to remind me about the persistence.xml

                    – Yusuf1494
                    Jan 28 '16 at 8:44















                  217














                  Your annotations look fine. Here are the things to check:



                  • make sure the annotation is javax.persistence.Entity, and not org.hibernate.annotations.Entity. The former makes the entity detectable. The latter is just an addition.


                  • if you are manually listing your entities (in persistence.xml, in hibernate.cfg.xml, or when configuring your session factory), then make sure you have also listed the ScopeTopic entity


                  • make sure you don't have multiple ScopeTopic classes in different packages, and you've imported the wrong one.






                  share|improve this answer


















                  • 15





                    Ah, thanks! Point 2 was the key, I had forgotten to put ScopeTopic in my annotatedClasses property list when creating the SessionFactory, n00b error!

                    – C0deAttack
                    Feb 10 '11 at 12:20






                  • 5





                    Point 1 was the key for me :D thanks

                    – PHP Avenger
                    Jul 3 '13 at 12:41






                  • 3





                    For those just hitting this comment. org.hibernate.annotations.Entity is deprecated in Hibernate 4. Point 1 does not apply anymore.

                    – gspatel
                    Apr 22 '14 at 3:50











                  • For me it was point 2, because I kept on editing the hibernate.cfg.xml in my build folder.

                    – Torsten
                    Oct 20 '15 at 12:14






                  • 1





                    Thanks to remind me about the persistence.xml

                    – Yusuf1494
                    Jan 28 '16 at 8:44













                  217












                  217








                  217







                  Your annotations look fine. Here are the things to check:



                  • make sure the annotation is javax.persistence.Entity, and not org.hibernate.annotations.Entity. The former makes the entity detectable. The latter is just an addition.


                  • if you are manually listing your entities (in persistence.xml, in hibernate.cfg.xml, or when configuring your session factory), then make sure you have also listed the ScopeTopic entity


                  • make sure you don't have multiple ScopeTopic classes in different packages, and you've imported the wrong one.






                  share|improve this answer













                  Your annotations look fine. Here are the things to check:



                  • make sure the annotation is javax.persistence.Entity, and not org.hibernate.annotations.Entity. The former makes the entity detectable. The latter is just an addition.


                  • if you are manually listing your entities (in persistence.xml, in hibernate.cfg.xml, or when configuring your session factory), then make sure you have also listed the ScopeTopic entity


                  • make sure you don't have multiple ScopeTopic classes in different packages, and you've imported the wrong one.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Feb 10 '11 at 12:14









                  BozhoBozho

                  499k112 gold badges971 silver badges1083 bronze badges




                  499k112 gold badges971 silver badges1083 bronze badges







                  • 15





                    Ah, thanks! Point 2 was the key, I had forgotten to put ScopeTopic in my annotatedClasses property list when creating the SessionFactory, n00b error!

                    – C0deAttack
                    Feb 10 '11 at 12:20






                  • 5





                    Point 1 was the key for me :D thanks

                    – PHP Avenger
                    Jul 3 '13 at 12:41






                  • 3





                    For those just hitting this comment. org.hibernate.annotations.Entity is deprecated in Hibernate 4. Point 1 does not apply anymore.

                    – gspatel
                    Apr 22 '14 at 3:50











                  • For me it was point 2, because I kept on editing the hibernate.cfg.xml in my build folder.

                    – Torsten
                    Oct 20 '15 at 12:14






                  • 1





                    Thanks to remind me about the persistence.xml

                    – Yusuf1494
                    Jan 28 '16 at 8:44












                  • 15





                    Ah, thanks! Point 2 was the key, I had forgotten to put ScopeTopic in my annotatedClasses property list when creating the SessionFactory, n00b error!

                    – C0deAttack
                    Feb 10 '11 at 12:20






                  • 5





                    Point 1 was the key for me :D thanks

                    – PHP Avenger
                    Jul 3 '13 at 12:41






                  • 3





                    For those just hitting this comment. org.hibernate.annotations.Entity is deprecated in Hibernate 4. Point 1 does not apply anymore.

                    – gspatel
                    Apr 22 '14 at 3:50











                  • For me it was point 2, because I kept on editing the hibernate.cfg.xml in my build folder.

                    – Torsten
                    Oct 20 '15 at 12:14






                  • 1





                    Thanks to remind me about the persistence.xml

                    – Yusuf1494
                    Jan 28 '16 at 8:44







                  15




                  15





                  Ah, thanks! Point 2 was the key, I had forgotten to put ScopeTopic in my annotatedClasses property list when creating the SessionFactory, n00b error!

                  – C0deAttack
                  Feb 10 '11 at 12:20





                  Ah, thanks! Point 2 was the key, I had forgotten to put ScopeTopic in my annotatedClasses property list when creating the SessionFactory, n00b error!

                  – C0deAttack
                  Feb 10 '11 at 12:20




                  5




                  5





                  Point 1 was the key for me :D thanks

                  – PHP Avenger
                  Jul 3 '13 at 12:41





                  Point 1 was the key for me :D thanks

                  – PHP Avenger
                  Jul 3 '13 at 12:41




                  3




                  3





                  For those just hitting this comment. org.hibernate.annotations.Entity is deprecated in Hibernate 4. Point 1 does not apply anymore.

                  – gspatel
                  Apr 22 '14 at 3:50





                  For those just hitting this comment. org.hibernate.annotations.Entity is deprecated in Hibernate 4. Point 1 does not apply anymore.

                  – gspatel
                  Apr 22 '14 at 3:50













                  For me it was point 2, because I kept on editing the hibernate.cfg.xml in my build folder.

                  – Torsten
                  Oct 20 '15 at 12:14





                  For me it was point 2, because I kept on editing the hibernate.cfg.xml in my build folder.

                  – Torsten
                  Oct 20 '15 at 12:14




                  1




                  1





                  Thanks to remind me about the persistence.xml

                  – Yusuf1494
                  Jan 28 '16 at 8:44





                  Thanks to remind me about the persistence.xml

                  – Yusuf1494
                  Jan 28 '16 at 8:44













                  19














                  Your entity may not listed in hibernate configuration file.






                  share|improve this answer



























                    19














                    Your entity may not listed in hibernate configuration file.






                    share|improve this answer

























                      19












                      19








                      19







                      Your entity may not listed in hibernate configuration file.






                      share|improve this answer













                      Your entity may not listed in hibernate configuration file.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Aug 11 '15 at 10:56









                      chetan.sankhalachetan.sankhala

                      3462 silver badges13 bronze badges




                      3462 silver badges13 bronze badges





















                          18














                          Mine was not having @Entity on the many side entity



                          @Entity // this was commented
                          @Table(name = "some_table")
                          public class ChildEntity
                          @JoinColumn(name = "parent", referencedColumnName = "id")
                          @ManyToOne
                          private ParentEntity parentEntity;






                          share|improve this answer





























                            18














                            Mine was not having @Entity on the many side entity



                            @Entity // this was commented
                            @Table(name = "some_table")
                            public class ChildEntity
                            @JoinColumn(name = "parent", referencedColumnName = "id")
                            @ManyToOne
                            private ParentEntity parentEntity;






                            share|improve this answer



























                              18












                              18








                              18







                              Mine was not having @Entity on the many side entity



                              @Entity // this was commented
                              @Table(name = "some_table")
                              public class ChildEntity
                              @JoinColumn(name = "parent", referencedColumnName = "id")
                              @ManyToOne
                              private ParentEntity parentEntity;






                              share|improve this answer















                              Mine was not having @Entity on the many side entity



                              @Entity // this was commented
                              @Table(name = "some_table")
                              public class ChildEntity
                              @JoinColumn(name = "parent", referencedColumnName = "id")
                              @ManyToOne
                              private ParentEntity parentEntity;







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Mar 25 at 23:21

























                              answered Mar 14 '16 at 17:03









                              YouYouYouYou

                              2,7521 gold badge18 silver badges46 bronze badges




                              2,7521 gold badge18 silver badges46 bronze badges





















                                  5














                                  Mostly in Hibernate , need to add the Entity class in hibernate.cfg.xml like-



                                  <hibernate-configuration>
                                  <session-factory>

                                  ....
                                  <mapping class="xxx.xxx.yourEntityName"/>
                                  </session-factory>
                                  </hibernate-configuration>





                                  share|improve this answer

























                                  • The syntax is incorrect! how can it be possible start with </...> and close in the same way?

                                    – elmigue017
                                    May 13 at 6:32











                                  • how did you know that .. see it

                                    – Sai prateek
                                    May 13 at 16:03















                                  5














                                  Mostly in Hibernate , need to add the Entity class in hibernate.cfg.xml like-



                                  <hibernate-configuration>
                                  <session-factory>

                                  ....
                                  <mapping class="xxx.xxx.yourEntityName"/>
                                  </session-factory>
                                  </hibernate-configuration>





                                  share|improve this answer

























                                  • The syntax is incorrect! how can it be possible start with </...> and close in the same way?

                                    – elmigue017
                                    May 13 at 6:32











                                  • how did you know that .. see it

                                    – Sai prateek
                                    May 13 at 16:03













                                  5












                                  5








                                  5







                                  Mostly in Hibernate , need to add the Entity class in hibernate.cfg.xml like-



                                  <hibernate-configuration>
                                  <session-factory>

                                  ....
                                  <mapping class="xxx.xxx.yourEntityName"/>
                                  </session-factory>
                                  </hibernate-configuration>





                                  share|improve this answer















                                  Mostly in Hibernate , need to add the Entity class in hibernate.cfg.xml like-



                                  <hibernate-configuration>
                                  <session-factory>

                                  ....
                                  <mapping class="xxx.xxx.yourEntityName"/>
                                  </session-factory>
                                  </hibernate-configuration>






                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited May 13 at 7:41

























                                  answered May 5 '16 at 6:37









                                  Sai prateekSai prateek

                                  4,9917 gold badges33 silver badges53 bronze badges




                                  4,9917 gold badges33 silver badges53 bronze badges












                                  • The syntax is incorrect! how can it be possible start with </...> and close in the same way?

                                    – elmigue017
                                    May 13 at 6:32











                                  • how did you know that .. see it

                                    – Sai prateek
                                    May 13 at 16:03

















                                  • The syntax is incorrect! how can it be possible start with </...> and close in the same way?

                                    – elmigue017
                                    May 13 at 6:32











                                  • how did you know that .. see it

                                    – Sai prateek
                                    May 13 at 16:03
















                                  The syntax is incorrect! how can it be possible start with </...> and close in the same way?

                                  – elmigue017
                                  May 13 at 6:32





                                  The syntax is incorrect! how can it be possible start with </...> and close in the same way?

                                  – elmigue017
                                  May 13 at 6:32













                                  how did you know that .. see it

                                  – Sai prateek
                                  May 13 at 16:03





                                  how did you know that .. see it

                                  – Sai prateek
                                  May 13 at 16:03











                                  0














                                  I had the same problem and I could solve it by adding the entity into persistence.xml.
                                  The problem was caused due to the fact that the entity was not added to the persistence config. Edit your persistence file:



                                  <persistence-unit name="MY_PU" transaction-type="RESOURCE_LOCAL">
                                  <provider>`enter code here`
                                  org.hibernate.jpa.HibernatePersistenceProvider
                                  </provider>
                                  <class>mypackage.MyEntity</class>


                                  ...






                                  share|improve this answer





























                                    0














                                    I had the same problem and I could solve it by adding the entity into persistence.xml.
                                    The problem was caused due to the fact that the entity was not added to the persistence config. Edit your persistence file:



                                    <persistence-unit name="MY_PU" transaction-type="RESOURCE_LOCAL">
                                    <provider>`enter code here`
                                    org.hibernate.jpa.HibernatePersistenceProvider
                                    </provider>
                                    <class>mypackage.MyEntity</class>


                                    ...






                                    share|improve this answer



























                                      0












                                      0








                                      0







                                      I had the same problem and I could solve it by adding the entity into persistence.xml.
                                      The problem was caused due to the fact that the entity was not added to the persistence config. Edit your persistence file:



                                      <persistence-unit name="MY_PU" transaction-type="RESOURCE_LOCAL">
                                      <provider>`enter code here`
                                      org.hibernate.jpa.HibernatePersistenceProvider
                                      </provider>
                                      <class>mypackage.MyEntity</class>


                                      ...






                                      share|improve this answer















                                      I had the same problem and I could solve it by adding the entity into persistence.xml.
                                      The problem was caused due to the fact that the entity was not added to the persistence config. Edit your persistence file:



                                      <persistence-unit name="MY_PU" transaction-type="RESOURCE_LOCAL">
                                      <provider>`enter code here`
                                      org.hibernate.jpa.HibernatePersistenceProvider
                                      </provider>
                                      <class>mypackage.MyEntity</class>


                                      ...







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Sep 3 '18 at 15:11









                                      Daniel Rodríguez

                                      1691 gold badge4 silver badges19 bronze badges




                                      1691 gold badge4 silver badges19 bronze badges










                                      answered Aug 25 '18 at 10:06









                                      enkaenka

                                      11 bronze badge




                                      11 bronze badge





















                                          0














                                          In my case a has to add my classes, when building the SessionFactory, with addAnnotationClass



                                          Configuration configuration.configure();
                                          StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
                                          SessionFactory sessionFactory = configuration
                                          .addAnnotatedClass(MyEntity1.class)
                                          .addAnnotatedClass(MyEntity2.class)
                                          .buildSessionFactory(builder.build());





                                          share|improve this answer



























                                            0














                                            In my case a has to add my classes, when building the SessionFactory, with addAnnotationClass



                                            Configuration configuration.configure();
                                            StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
                                            SessionFactory sessionFactory = configuration
                                            .addAnnotatedClass(MyEntity1.class)
                                            .addAnnotatedClass(MyEntity2.class)
                                            .buildSessionFactory(builder.build());





                                            share|improve this answer

























                                              0












                                              0








                                              0







                                              In my case a has to add my classes, when building the SessionFactory, with addAnnotationClass



                                              Configuration configuration.configure();
                                              StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
                                              SessionFactory sessionFactory = configuration
                                              .addAnnotatedClass(MyEntity1.class)
                                              .addAnnotatedClass(MyEntity2.class)
                                              .buildSessionFactory(builder.build());





                                              share|improve this answer













                                              In my case a has to add my classes, when building the SessionFactory, with addAnnotationClass



                                              Configuration configuration.configure();
                                              StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
                                              SessionFactory sessionFactory = configuration
                                              .addAnnotatedClass(MyEntity1.class)
                                              .addAnnotatedClass(MyEntity2.class)
                                              .buildSessionFactory(builder.build());






                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered Sep 4 '18 at 10:02









                                              VLazzarovaVLazzarova

                                              234 bronze badges




                                              234 bronze badges



























                                                  draft saved

                                                  draft discarded
















































                                                  Thanks for contributing an answer to Stack Overflow!


                                                  • Please be sure to answer the question. Provide details and share your research!

                                                  But avoid


                                                  • Asking for help, clarification, or responding to other answers.

                                                  • Making statements based on opinion; back them up with references or personal experience.

                                                  To learn more, see our tips on writing great answers.




                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function ()
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4956855%2fhibernate-problem-use-of-onetomany-or-manytomany-targeting-an-unmapped-clas%23new-answer', 'question_page');

                                                  );

                                                  Post as a guest















                                                  Required, but never shown





















































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown

































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown







                                                  Popular posts from this blog

                                                  Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                                                  SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                                                  은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현