[jboss-user] [JBoss Seam] - Howto prevent SEAM from mapping POJO ?

w17chm4n do-not-reply at jboss.com
Tue Oct 30 06:51:15 EDT 2007


Hi ! I have another problem. As I need a drop-down menu in my application, and data from which it`s created isn`t in database, I`m trying to do sth like this (look @ questionTypeList):


  | @Stateful
  | @Scope(ScopeType.SESSION)
  | @Name("QuestionController")
  | public class QuestionControllerBean implements QuestionController {
  |     
  |     @Logger
  |     private Log log;
  |     
  |     @In(create = true)
  |     private QuestionManager questionManager;
  |     
  |     @In(create = true)
  |     private PictureManager pictureManager;
  |     
  |     @In(required = false)
  |     private QuestionCategory questionCategory;
  |     
  |     @In(required = false)
  |     private Question question;
  |     
  |     @DataModel("answerList")
  |     private List<Answer> answerList;
  |     
  |     @In(required = false)
  |     @DataModelSelection("answerList")
  |     private Answer answer;
  |     
  |     @DataModel("questionTypeList")
  |     private List<QuestionType> questionTypeList;
  |     
  |     @In(required = false)
  |     @DataModelSelection("questionTypeList")
  |     private QuestionType questionType;
  |     
  |     @Out(required = false)
  |     private Picture picture;
  |     
  |     private int fileSize;
  |     private byte [] data;
  |     private String fileName;
  |     private String contentType;
  |     
  |     public void addQuestion() {
  |         if(fileName == null) {
  |             question.setQuestionType(questionType.getQuestionType());
  |             question.setCategory(questionCategory);
  |             questionManager.addQuestion(question);
  |         } else {
  |             picture.setQuestion(question);
  |             question.setPicture(picture);
  |             question.setQuestionType(questionType.getQuestionType());
  |             question.setCategory(questionCategory);
  |             questionManager.addQuestion(question);
  |             pictureManager.addPicture(picture);
  |             
  |         }
  |     }
  |     
  |     public void removeQuestion() {
  |     }
  |     
  |     public void selectQuestion() {
  |     }
  |     
  |     public void addAnswer() {
  |     }
  |     
  |     public void removeAnswer() {
  |     }
  |     
  |     @Factory("questionTypeList")
  |     public void createQuestionTypeList() {
  |         questionTypeList = new ArrayList<QuestionType>();
  |         questionTypeList.add(new QuestionType(Commons.INPUT,"Input answer as text"));
  |         questionTypeList.add(new QuestionType(Commons.SELECT_ONE,"Select one answer"));
  |         questionTypeList.add(new QuestionType(Commons.SELECT_MANY,"Select many answers"));
  |     }
  |     
  |     public void addPicture() {
  |         picture = new Picture(data, fileName, new Date());
  |         picture.setQuestion(question);
  |     }
  |     
  |     public byte[] getData() {
  |         return data;
  |     }
  |     
  |     public void setData(byte[] data) {
  |         this.data = data;
  |     }
  |     
  |     public String getFileName() {
  |         return fileName;
  |     }
  |     
  |     public void setFileName(String fileName) {
  |         this.fileName = fileName;
  |     }
  |     
  |     public String getContentType() {
  |         return contentType;
  |     }
  |     
  |     public void setContentType(String contentType) {
  |         this.contentType = contentType;
  |     }
  |     
  |     public int getFileSize() {
  |         return fileSize;
  |     }
  |     
  |     public void setFileSize(int fileSize) {
  |         this.fileSize = fileSize;
  |     }
  |     
  |     @Remove @Destroy
  |     public void destroy() {}
  |     
  | }
  | 

It uses a POJO


  | public class QuestionType {
  |     
  |     private int QuestionType;
  |     private String label;
  |     
  |     public QuestionType() {
  |     }
  |     
  |     public QuestionType(int questionType, String label) {
  |         this.QuestionType = questionType;
  |         this.label = label;
  |     }
  | 
  |     public int getQuestionType() {
  |         return QuestionType;
  |     }
  | 
  |     public void setQuestionType(int QuestionType) {
  |         this.QuestionType = QuestionType;
  |     }
  | 
  |     public String getLabel() {
  |         return label;
  |     }
  | 
  |     public void setLabel(String label) {
  |         this.label = label;
  |     }
  |     
  | }
  | 

and a simple class for static variables


  | public class Commons {
  |     
  |     public static final int INPUT = 0;
  |     public static final int SELECT_ONE = 1;
  |     public static final int SELECT_MANY = 2;
  |     
  | }
  | 

When I try to submit my form (addQuestion method) i get the following error:


  | org.hibernate.MappingException: Unknown entity: java.lang.Object
  | 

As i think, the problem is that JBoss is trying to map POJO and the Commons class to the database, because these files r in the same jar as the normal seam components and entities.

So, is there a way to prevent seam from trying to map those two files?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4100172#4100172

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4100172



More information about the jboss-user mailing list