Hello everybody, I hava problem with foreign key - field. This is my Java
class:
package org.cimlvin.domain.model;
import java.io.Serializable;
import java.sql.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import org.apache.tapestry.beaneditor.Validate;
// TODO: Auto-generated Javadoc
/**
* The Class QuestionaireQuestion.
*/
@SuppressWarnings("unchecked")
@Entity
@Table(name = "QUESTIONS")
@NamedQueries( {
@NamedQuery(name = "QuestionaireQuestion.findByType", query =
"select e
from QuestionaireQuestion e where e.questionType = ?1"),
@NamedQuery(name = "QuestionaireQuestion.findByTitle", query =
"select e
from QuestionaireQuestion e where e.title = ?1"),
@NamedQuery(name = "QuestionaireQuestion.findById", query =
"select e from
QuestionaireQuestion e where e.id = ?1"),
@NamedQuery(name = "QuestionaireQuestion.findAll", query =
"select e from
QuestionaireQuestion e") })
public class QuestionaireQuestion implements Serializable, Comparable {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -9137096316582763142L;
/** The _title. */
private String _title = "";
/** The _create date. */
private Date _createDate = new Date(System.currentTimeMillis());
/** The _questionType. */
private QuestionType _questionType;
/** The id. */
private long id;
/*
* (non-Javadoc)
*
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
public int compareTo(Object o) {
return String.valueOf(this).compareTo(String.valueOf(o));
}
/**
* Gets the id.
*
* @return the id
*/
@Id
@Column(name = "QUES_ID")
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {
return id;
}
/**
* Sets the id.
*
* @param id
* the new id
*/
public void setId(long id) {
this.id = id;
}
/**
* Gets the title.
*
* @return the title
* */
@Column(name = "TITLE", nullable = false)
public String getTitle() {
return _title;
}
/**
* Sets the title.
*
* @param title
* the new title
*/
@Validate("required")
public void setTitle(String title) {
_title = title;
}
/**
* Gets the creates the date.
*
* @return the creates the date
*/
@Column(name = "CREATE_DATE", nullable = false)
public Date getCreateDate() {
return _createDate;
}
/**
* Sets the creates the date.
*
* @param date
* the new creates the date
*/
@Validate("required")
public void setCreateDate(Date date) {
_createDate = date;
}
/**
* Gets the question type.
*
* @return the question type
*/
@ManyToOne
@JoinColumns( { @JoinColumn(name = "TOQ_TOQ_ID", nullable = false) })
@Basic(fetch = FetchType.LAZY)
public QuestionType getQuestionType() {
return _questionType;
}
/**
* Sets the question type.
*
* @param type
* the new question type
*/
@Validate("required")
public void setQuestionType(QuestionType type) {
_questionType = type;
}
}
My page:
ManageQuestion.java:
package org.cimlvin.web.pages.admin;
import java.util.List;
import org.acegisecurity.annotation.Secured;
import org.apache.tapestry.annotations.Property;
import org.apache.tapestry.annotations.Service;
import org.apache.tapestry.ioc.annotations.Inject;
import org.cimlvin.domain.model.QuestionaireQuestion;
import org.cimlvin.service.QuestionManager;
@Secured("ROLE_ADMIN")
public class ManageQuestions {
/** The question manager **/
@Inject
@Service("QuestionManager")
private QuestionManager questionMgr;
/** The question **/
@SuppressWarnings("unused")
@Property
private QuestionaireQuestion question;
public List<QuestionaireQuestion> getquestions() {
return questionMgr.getAllQuestions();
}
}
ManageQuestions.tml:
<t:layout
title="literal:Administration Area - Manage Questions"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<div class="post">
<h2 class="title"> # Administration Area - Manage Questions </h2>
<div class="entry">
<h3>Question List</h3>
<t:grid t:source="questions" row="question" rowsPerPage="20">
<t:parameter name="titleCell">
<t:pagelink t:page="admin/ManageQuestion"
t:context="question.id">${question.title}</t:pagelink>
</t:parameter>
<t:parameter name="questionTypeCell">
${question.questionType.Name}
</t:parameter>
</t:grid>
</div>
</div>
</t:layout>
So my class has 4 properties, but when I try to see it, I see only 3. grib
shows me id,title and create date. It did show me QuestionType (foreign
key). I don`t understand why..
Thank you.
--
View this message in context:
http://www.nabble.com/Tapestry-5%2C-problem-with-foreign-field-tp19151921p19151921.html
Sent from the Tapestry - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]