0

データベース接続には、プラグインHibernate Tools(JBoss by red hat)を備えたEclipseIndigoを使用しています。MicrosoftSQLServer2008JDBCDriverを使用しています。

リバースエンジニアリングツール(Hibernateコード生成構成ツール)を使用して、「文字列」タイプのフィールドではなく、データベーステーブルに基づいてクラスを生成しようとすると、「シリアル化可能」タイプのフィールドが表示されます。

import java.io.Serializable;

/**
* Customers generated by hbm2java
*/
public class Customers implements java.io.Serializable {

   private Serializable customerId;
   private Serializable companyName;
   private Serializable contactName;
   private Serializable contactTitle;
   private Serializable address;
   private Serializable city;
   private Serializable region;
   private Serializable postalCode;
   private Serializable country;
   private Serializable phone;
   private Serializable fax;

   public Customers() {
   }

   public Customers(Serializable customerId, Serializable companyName) {
      this.customerId = customerId;
      this.companyName = companyName;
   }

   public Customers(Serializable customerId, Serializable companyName,
         Serializable contactName, Serializable contactTitle,
         Serializable address, Serializable city, Serializable region,
         Serializable postalCode, Serializable country, Serializable phone,
         Serializable fax) {
      this.customerId = customerId;
      this.companyName = companyName;
      this.contactName = contactName;
      this.contactTitle = contactTitle;
      this.address = address;
      this.city = city;
      this.region = region;
      this.postalCode = postalCode;
      this.country = country;
      this.phone = phone;
      this.fax = fax;
   }

   public Serializable getCustomerId() {
      return this.customerId;
   }

   public void setCustomerId(Serializable customerId) {
      this.customerId = customerId;
   }

   public Serializable getCompanyName() {
      return this.companyName;
   }

   public void setCompanyName(Serializable companyName) {
      this.companyName = companyName;
   }

   public Serializable getContactName() {
      return this.contactName;
   }

   public void setContactName(Serializable contactName) {
      this.contactName = contactName;
   }

   public Serializable getContactTitle() {
      return this.contactTitle;
   }

   public void setContactTitle(Serializable contactTitle) {
      this.contactTitle = contactTitle;
   }

   public Serializable getAddress() {
      return this.address;
   }

   public void setAddress(Serializable address) {
      this.address = address;
   }

   public Serializable getCity() {
      return this.city;
   }

   public void setCity(Serializable city) {
      this.city = city;
   }

   public Serializable getRegion() {
      return this.region;
   }

   public void setRegion(Serializable region) {
      this.region = region;
   }

   public Serializable getPostalCode() {
      return this.postalCode;
   }

   public void setPostalCode(Serializable postalCode) {
      this.postalCode = postalCode;
   }

   public Serializable getCountry() {
      return this.country;
   }

   public void setCountry(Serializable country) {
      this.country = country;
   }

   public Serializable getPhone() {
      return this.phone;
   }

   public void setPhone(Serializable phone) {
      this.phone = phone;
   }

   public Serializable getFax() {
      return this.fax;
   }

   public void setFax(Serializable fax) {
      this.fax = fax;
   }

}
4

2 に答える 2

0

次のタイプマッピング要素をhibernate.reveng.xmlに追加します

**<type-mapping>
  <sql-type jdbc-type="NVARCHAR" hibernate-type="string"/>
  <sql-type jdbc-type="VARCHAR" hibernate-type="string"/>
</type-mapping>**
于 2013-02-13T12:28:54.993 に答える
0

「hibernate.reveng.xml」を編集し、JDBC フィールドを次のような Hibernate タイプにマップする必要があります。

<type-mapping>
    <sql-type jdbc-type="NUMERIC" precision='20' scale="0" hibernate-type="Long" />
</type-mapping>

また、より具体的な答えを得るには、Customer(s) テーブルのデータベース テーブル構造を指定するだけです。

お役に立てれば。

于 2011-10-11T09:52:11.533 に答える