English 中文(简体)
为什么这种简单的日本人民军协会的众多关系发挥作用?
原标题:Why isn t this simple JPA ManyToOne relationship working?

I m 采用JPA和Java E 5(IBM RAD 7.5和Web Sphere 7)。 我将问题简化为以下例子......

我有一个项目和一个用户。 表格如下:

PROJECT
--
id
name
projectmanagerid // is a User

USER
--
id
username

我的班子就是这样:

@Entity
@Table(name="PROJECT")
class Project
  @Id
  @GeneratedValue(...)
  Long id;
  String name;
  @ManyToOne(fetch=FetchType.EAGER)
  @JoinColumn(name="projectmanagerid");
  User projectManager;

@Entity
@Table(name="USER")
class User
  @Id
  @GeneratedValue(...)
  Long id;
  String username;

检索我的项目一:

Query query = em.createQuery("select distinct p from Project p");
query.getResult...

除<代码>项目外,所有工程项目。

表格 • 促使用户有人居住? 我做了什么错误?

Any suggestions are greatly appreciated!

抢劫

最佳回答

我对我的问题的回答是这样。 希望它可以帮助他人。

在IBM RAD 7.5中,JPA项目财产有一个称为“Platform”的环境。 违约值是“RAD JPA平台”。 当我改变“基因”后,它现在就投入使用。

注:我还根据传译建议修改了@JoinColum,Column,但并不肯定这是否可行。

感谢大家。

抢劫

问题回答

如果是这样的话,你就应该能够用“TheColumn annotation”来绘制这方面的地图,因为加入一栏就是在关系的另一侧点。

Project -> (has a) User then Project has @Column with name="projectmanagerid"

如果在另一个地方有用户参考项目,那么你本会这样做。

User -> (has a) Project then Project has @JoinColumn with name="projectid"

Presently you are stating the the user table has a reference column called projectmanagerid which is not the case.

I hope this helps, TomRed





相关问题
Recommended way to develop using Jetty and Eclipse

I am currently developing a J2EE application and I would like to use Jetty. I would like to have iot integrated with Eclipse, so I could debug the appliaction. I ve tried out couple of plugins (...

Call function periodically in Java

we need run one function periodically in Java web application . How to call function of some class periodically ? Is there any way that call function when some event occured like high load in server ...

Why make an EJB rather than a Web Service?

I would have thought that there is a lot of information out there on this, but I haven t found anything that really answers my question. What are the advantages of making an EJB rather than a web ...

Where should I put this configuration setting?

I m designing a fairly small web application which will run on a Sun application server (v9.1). It only has a few pages, no database of its own, and will retrieve/update data via web services. There s ...

JNDI Names -- Is Prefix "jdbc/" needed?

What s up with JNDI names? I m trying to get a javax.sql.DataSource using the new annotations feature of Java 5. It s not working for me, so I want to ask... I have a in my web.xml, inside of it is ...

hibernate interceptors : afterTransactionCompletion

I wrote a Hibernate interceptor : public class MyInterceptor extends EmptyInterceptor { private boolean isCanal=false; public boolean onSave(Object entity, Serializable arg1, Object[] arg2, String[]...

热门标签