-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Unmapped Class
PostPosted: Fri Jul 11, 2014 5:44 am 
Newbie

Joined: Fri Jul 11, 2014 5:36 am
Posts: 2
Hello,

I am trying to use a Set in my class and persist it to a database. Whenever I load the application, I am given the following error.

'Use of @OneToMany or @ManyToMany targeting an unmapped class'

Here is the class that has the Set

Code:
package com.provisionworks.dao;

import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.MapKey;
import javax.persistence.MapKeyColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
* represents a user
* @author Administrator
*
*/
@Entity
@Table(name = "pw_users")
public class User {
   
   @Id @GeneratedValue
   @Column(name = "ID")
   private int ID;
   
   @Column(nullable=false)
   private String name;
   
   @Column(nullable=false)
   private String password;
   
   @Column(nullable=false)
   private String organization;
   
   @Column(nullable=false)
   private String email;
   
   @OneToMany(cascade=CascadeType.ALL, targetEntity=App.class, mappedBy="user")
   //@JoinColumn(name="app.ID")
   private Set<App> favoriteApplications;
   
   @Column(nullable=false)
   private long token;
   
   public User(String name, String password, String email, String organization){
      this.name = name;
      this.password = password;
      this.email = email;
      this.organization = organization;
      this.favoriteApplications = new HashSet<App>();
   }

   public int getID() {
      return ID;
   }

   public void setID(int iD) {
      ID = iD;
   }

   public String getName() {
      return name;
   }

   public void setName(String name) {
      this.name = name;
   }

   public String getPassword() {
      return password;
   }

   public void setPassword(String password) {
      this.password = password;
   }

   public String getOrganization() {
      return organization;
   }

   public void setOrganization(String organization) {
      this.organization = organization;
   }

   public String getEmail() {
      return email;
   }

   public void setEmail(String email) {
      this.email = email;
   }
   
   public void addApplication(App application){
      this.favoriteApplications.add(application);
   }
   
   public void deleteApplication(App application){
      this.favoriteApplications.remove(application);
   }

}




Here is the class that says it is not mapped.

Code:
package com.provisionworks.dao;


import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "pw_apps")
public class App {
   
   @Id @GeneratedValue
   @Column(name = "ID")
   private int ID;
   
   @Column(nullable=false)
   private String description;
   
   @Column(nullable=false)
   private String UIName;
   
   //@Column(nullable=false)
   //private EnumMap<PackageManager, String> relations;

   @Column(nullable=false)
   private String version;
   
   public App(String description, String UIName, String version){
      this.description = description;
      this.UIName = UIName;
      this.version = version;
      //this.setRelations(new EnumMap<PackageManager, String>(PackageManager.class));
   }

   public int getID() {
      return ID;
   }

   public void setID(int iD) {
      ID = iD;
   }

   public String getDescription() {
      return description;
   }

   public void setDescription(String description) {
      this.description = description;
   }

   public String getUIName() {
      return UIName;
   }

   public void setUIName(String uIName) {
      UIName = uIName;
   }

   public String getVersion() {
      return version;
   }

   public void setVersion(String version) {
      this.version = version;
   }

   //public EnumMap<PackageManager, String> getRelations() {
   //   return relations;
   //}

   //public void setRelations(EnumMap<PackageManager, String> relations) {
      //this.relations = relations;
   //}
   
   /**
    * Add a relation to a package manager and a package name.
    * i.e Aptitude - apache2
    * @param pm
    * @param packageName
    */
   //public void addRelation(PackageManager pm, String packageName){
   //   this.relations.put(pm, packageName);
   //}

}



I thought that the App class was mapped with the Entity Annotation at the top? Am I trying to put the Set in the Database wrong? Thank you for any help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.