Hello guys,

My main problem is that i cant write and i couldnt find the correct
query form to fetch data from join tables , for example in my
project , here's my database form ;

Student Table                 Result Table
-studentId                       -resultId
-studentName                 -resultPoint
-studentSurname             -studentId   (FK with Student Table)
-..                                   -..
-..                                   -..
-..

what i want to ask is that i cant fetch the resultPoint with using
studentId and please help me to fix this problem, here's my code ;



Student.java
********************************************
package tr.edu.gsu.yds.shared.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import net.sf.gilead.pojo.gwt.LightEntity;


//RESULT DOMAIN

@Entity
@Table(name = "sonuc")
public class Sonuc extends LightEntity implements Serializable
{
        private static final long serialVersionUID = 6L;

        private String sonucId;
        private Integer sonucPuan;
        private String sonucSeviye;
        private Ogrenci ogrenci;


        @Id
        @Column(name = "sonucId", nullable = false, length=10)
        public String getSonucId() {
                return sonucId;
        }

        public void setSonucId(String sonucId) {
                this.sonucId = sonucId;
        }

        @Column(name = "sonucPuan", nullable = false, length=3)
        public Integer getSonucPuan() {
                return sonucPuan;
        }

        public void setSonucPuan(Integer sonucPuan) {
                this.sonucPuan = sonucPuan;
        }

        @Column(name = "sonucSeviye", length=25)
        public String getSonucSeviye() {
                return sonucSeviye;
        }

        public void setSonucSeviye(String sonucSeviye) {
                this.sonucSeviye = sonucSeviye;
        }

        @OneToOne(fetch = FetchType.LAZY)
        @PrimaryKeyJoinColumn
        public Ogrenci getOgrenci()
        {
                return ogrenci;
        }

        public void setOgrenci( Ogrenci ogrenci )
        {
                this.ogrenci = ogrenci;
        }


}

----------------------------------------------------------------------------------------------------




SonucDao.java
********************************************
package tr.edu.gsu.yds.server.dao;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

import tr.edu.gsu.yds.server.util.GileadHibernateUtil;
import tr.edu.gsu.yds.shared.domain.Sonuc;

//Result - (point result of a student)
public class SonucDao
{
        //gets the result with studentNo
        public Sonuc getSonuc( String ogrenciNo ) throws
IllegalArgumentException
        {
                Session session = null;
                Transaction transaction = null;
                try
                {
                        session = 
GileadHibernateUtil.getSessionFactory().openSession();
                        transaction = session.beginTransaction();

                StringBuffer mysqlQuery = new StringBuffer();

                //here, i dont' know if this query is correct, that's my main
question.
                mysqlQuery.append("from Sonuc sonuc where
sonuc.ogrenci=:ogrenciNo");

                        Query query = 
session.createQuery(mysqlQuery.toString());
                        query.setString("ogrenciNo", ogrenciNo);


                        Sonuc sonuc = (Sonuc) query.uniqueResult();
                        transaction.commit();

                        return sonuc;
                }
                catch ( RuntimeException e )
                {
                        transaction.rollback();
                        throw e;
                }
                finally
                {
                        if ( session != null )
                        {
                                session.close();
                        }
                }
        }

}

-----------------------------------------------------------------------------------------------------




And here , i'm trying to fetch the data from database and put the into
a CELLTABLE , but the return value is NULL.
*****************************************
package tr.edu.gsu.yds.client.controller.ogrenci;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;

import tr.edu.gsu.yds.client.remote.YdsRemoteService;
import tr.edu.gsu.yds.client.remote.YdsRemoteServiceAsync;
import
tr.edu.gsu.yds.client.view.ogrenci.sinavislemleri.SinavSonucuGoruntuleme;
import tr.edu.gsu.yds.shared.domain.Sonuc;

public class OgrenciSinavSonucuGoruntulemeController
{
        private YdsRemoteServiceAsync ydsRemoteServiceAsync =
GWT.create( YdsRemoteService.class );

        private SinavSonucuGoruntuleme ogrenciSinavSonucuGoruntulemeSayfasi;

        private List<Sonuc> sonucListesi = new ArrayList<Sonuc>();



        public
OgrenciSinavSonucuGoruntulemeController( SinavSonucuGoruntuleme
ogrenciSinavSonucuGoruntulemeSayfasi )
        {
                this.ogrenciSinavSonucuGoruntulemeSayfasi =
ogrenciSinavSonucuGoruntulemeSayfasi;
        }

        public void send()
        {

                 //here , 07401478  is the studentNo
                ydsRemoteServiceAsync.getSonuc( "07401478", new
AsyncCallback<Sonuc>()
                {

                        @Override
                        public void onSuccess( Sonuc result )
                        {
                            sonucListesi.add( result ) ;
        
ogrenciSinavSonucuGoruntulemeSayfasi.getSinavSonucCellWidget().refresh( 
sonucListesi );

                        }

                        @Override
                        public void onFailure( Throwable caught )
                        {
                                Window.alert( " Failure error " );

                        }
                } );

        }

}



-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to