Veritabanı programımı herhangi bir hql sorgusunu yürütmek için bir işlevle genişletmeye çalışıyorum. Neredeyse bitti ama şu süreçte bir hata alıyorum.Hazırda bekletme HQL Sorgusu'ndan yanlış SQL Sorgusu oluşturuyor gibi görünüyor
select p.reviews, p.title from Product p
Bu hql sorgu aşağıdaki gibi bir sql sorgusunda dönüştürülür. Eğer açıkça görebileceğiniz gibi
Hibernate: select . as col_0_0_, product0_.title as col_1_0_, reviews1_.account_number as account_1_2_, reviews1_.product_id as product_2_2_, reviews1_.points as points3_2_, reviews1_.review as review4_2_ from dbprak12.view_product_meta product0_ inner join dbprak12.view_customer_evaluates reviews1_ on product0_.product_id=reviews1_.product_id
, col_0_0_ olarak sql devlet kodu 42601. Çünkü "ile bir hata var atılacaktır. .. "doğru sözdizimi değil. Ancak, neden hazırda bekletme bu sorguyu oluşturduğunu anlamıyorum.
Product.hbm.xml
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="media.definitions.Product" table="dbprak12.view_product_meta">
<id name="asin" column="product_id">
<generator class="native" />
</id>
<property name="title" column="title" />
<property name="avgRating" column="rating" />
<property name="salesRank" column="sales_rank" />
<property name="picUrl" column="picture" />
<set name="reviews" cascade="all" inverse="true" lazy="true">
<key column="product_id" />
<one-to-many class="media.definitions.Review" />
</set>
<set name="categories" table="dbprak12.view_product_in_category" inverse="false" lazy="true" fetch="select" cascade="all">
<key column="product_id" />
<many-to-many column="category_id" class="media.definitions.Category" />
</set>
<joined-subclass name="media.definitions.Book" table="dbprak12.view_book">
<key column="product_id" />
<property name="isbn" column="isbn" />
<property name="publishers" column="publisher" />
<property name="pubDate" column="publication" />
<property name="pages" column="pages" />
</joined-subclass>
<joined-subclass name="media.definitions.DVD" table="dbprak12.view_dvd">
<key column="product_id" />
<property name="format" column="fformat" />
<property name="regionCode" column="region_code" />
<property name="runningTime" column="running_time" />
</joined-subclass>
<joined-subclass name="media.definitions.Music" table="dbprak12.view_cd">
<key column="product_id" />
<property name="labels" column="label" />
<property name="releaseDate" column="release_date" />
</joined-subclass>
</class>
</hibernate-mapping>
Review.hbm.xml
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="media.definitions.Review" table="dbprak12.view_customer_evaluates">
<composite-id>
<key-property name="accountNumber" column="account_number" />
<key-many-to-one name="product" class="media.definitions.Product" lazy="false">
<column name="product_id"></column>
</key-many-to-one>
</composite-id>
<property name="rating" column="points" />
<property name="content" column="review" />
</class>
</hibernate-mapping>
Düzenleme:: My hazırda yapılandırma dosyası: hazırda
aşağıdaki iki xml eşleştirmeleri kullanırlar. cfg.xml
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="hibernate.current_session_context_class">thread</property>
<mapping resource="Product.hbm.xml"/>
<mapping resource="Category.hbm.xml"/>
<mapping resource="Review.hbm.xml"/>
<mapping resource="Person.hbm.xml"/>
<mapping resource="Offer.hbm.xml"/>
</session-factory>
</hibernate-configuration>
db2Module.properties
#
# Database module to load
#
middleware.module:media.mediadbimpl.DB2Module
#
# Database properties
#
db.jdbc.dialect:org.hibernate.dialect.DB2Dialect
db.jdbc.driver:com.ibm.db2.jcc.DB2Driver
db.jdbc.url:jdbc:db2://anyurl.de:50001/datasource
db.user:dbuser
db.password:.dbpass.
Talep Elinden 'hibernate.cfg.xml' dosyasını bir atış ver lütfen? – hd1
Gönderiyi düzenledim :) Daha fazla özellik dosyasına sahip, sadece bağlantı verilerini ve lehçeyi ayarlıyor (DB2) –
Açıkça kullandığınız diyalektiğini bildirmeyi deneyin – hd1