JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Object Relational Mapping » Hibernate  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to postflat modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 hibernate 對上 sql server問題
sample33





發文: 7
積分: 0
於 2015-05-16 02:24 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Table
Msg ---> Msgid Topicid

Topic ---> Topicid TopicName

我讓hibernate直接長出來 大概是

Msg hbm
<class name="coffeeBean.Msg" table="MSG" catalog="DBofDB" optimistic-lock="version">
<id name="msgId" type="int">
<column name="MSG_ID" />
<generator class="assigned" />
</id>
<many-to-one name="msgTopic" class="coffeeBean.MsgTopic" fetch="select">
<column name="MSG_TOPIC_ID" not-null="true" />
</many-to-one> ...............
Msg class
public class Msg {

  private int msgId;
  private MsgTopic msgTopic;
......

Topic hbm
<class name="coffeeBean.MsgTopic" table="MSG_TOPIC" catalog="DBofDB" optimistic-lock="version">
<id name="msgTopicId" type="int">
<column name="MSG_TOPIC_ID" />
<generator class="assigned" />
</id>
<property name="topicName" type="serializable">
<column name="TOPIC_NAME" not-null="true" />
</property>
<set name="msgs" table="MSG" inverse="true" lazy="true" fetch="select">
<key>
<column name="MSG_TOPIC_ID" not-null="true" />
</key>
<one-to-many class="coffeeBean.Msg" />
</set>
</class>

Topic class

public class MsgTopic {

  private int msgTopicId;
  private String topicName;
  private Set msgs = new HashSet(0);

  public MsgTopic() {
  }........

請問 能夠使用他提供的這些 能夠像sql 裡面的
select TOPICNAME from MSG m1 join MSGTOPIC m2 on m1.MSGTOPICID=m2.MSGTOPICID
讓我能夠直接從msg的bean中 取得 關聯table topic 中的topicName嗎
或是其他方法 也能夠產生類似功能


sample33 edited on 2015-05-16 02:37
reply to postreply to post
話題樹型展開
人氣 標題 作者 字數 發文時間
808 hibernate 對上 sql server問題 sample33 1680 2015-05-16 02:24
850 Re:hibernate 對上 sql server問題 sample33 2134 2015-05-16 06:40
» JWorld@TW »  Object Relational Mapping » Hibernate

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8