Java

hibernate jointable kullanımı


import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;

/**
 *
 * @author Muhammed YÜRÜRDURMAZ
 */
@Entity
@Table(name = "KISI_TBL")
public class Kisi implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "KISI_ID")
    private int KisiId;
    @Column(name="ISIM", length=64, nullable=false)
    private String isim;
    @ManyToMany
    @JoinTable(name = "KISI_TELEFON_TBL", joinColumns = {
        @JoinColumn(name = "KISI_ID")},
    inverseJoinColumns = {
        @JoinColumn(name = "TELEFON_ID")})
    private List<Telefon> telefonlar;

    /**
     * @return the KisiId
     */
    public int getKisiId() {
        return KisiId;
    }

    /**
     * @param KisiId the KisiId to set
     */
    public void setKisiId(int KisiId) {
        this.KisiId = KisiId;
    }

    /**
     * @return the isim
     */
    public String getIsim() {
        return isim;
    }

    /**
     * @param isim the isim to set
     */
    public void setIsim(String isim) {
        this.isim = isim;
    }

    /**
     * @return the telefonlar
     */
    public List<Telefon> getTelefonlar() {
        return telefonlar;
    }

    /**
     * @param telefonlar the telefonlar to set
     */
    public void setTelefonlar(List<Telefon> telefonlar) {
        this.telefonlar = telefonlar;
    }
}



import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;

/**
 *
 * @author Muhammed YÜRÜRDURMAZ
 */
@Entity
@Table(name = "TELEFON_TBL")
public class Telefon implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "TELEFO_ID")
    private int telefonId;
    @Column(name = "TELEFON_NO", length = 13, nullable = false)
    private String telefonNo;
    @ManyToMany(mappedBy="telefonlar")
    private List<Kisi> kisiler;

    /**
     * @return the telefonId
     */
    public int getTelefonId() {
        return telefonId;
    }

    /**
     * @param telefonId the telefonId to set
     */
    public void setTelefonId(int telefonId) {
        this.telefonId = telefonId;
    }

    /**
     * @return the telefonNo
     */
    public String getTelefonNo() {
        return telefonNo;
    }

    /**
     * @param telefonNo the telefonNo to set
     */
    public void setTelefonNo(String telefonNo) {
        this.telefonNo = telefonNo;
    }

    /**
     * @return the kisiler
     */
    public List<Kisi> getKisiler() {
        return kisiler;
    }

    /**
     * @param kisiler the kisiler to set
     */
    public void setKisiler(List<Kisi> kisiler) {
        this.kisiler = kisiler;
    }
}

Bookmark and Share
Tags: , , ,

Related posts

Java

Comments (0)

Permalink

log4j harici properties dosyası okuma

public static void main(String args[]) {
  PropertyConfigurator.configure("c:\\dizin\\log4j.properties");
  log = Logger.getLogger("class adı");
  log.info("deneme");
}
Bookmark and Share
Tags: ,

Related posts

Java
Yazılım

Comments (0)

Permalink

hibernate blob kullanarak resim kaydetme


import java.io.Serializable;
import java.sql.Blob;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;

@Entity(name="resim")
public class Resim implements Serializable {
    @Column(name="id")
    @Id
    private int id;
    @Column(name="resim")
    @Lob
    private Blob resim;

    /**
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * @return the resim
     */
    public Blob getResim() {
        return resim;
    }

    /**
     * @param resim the resim to set
     */
    public void setResim(Blob resim) {
        this.resim = resim;
    }

}

Kullanım örneği

Resim r = new Resim();
r.setResim(Hibernate.createBlob(new FileInputStream("resim.jpg")));
s.save(r);
Bookmark and Share
Tags: , , ,

Related posts

Java

Comments (0)

Permalink

netbeans web servisleri 64bit

64bit windows 7 üzerine 32bit jdk kurup web servislerini çalıştırmaya çalıştığınızda çalışmıyor. 64bit jdk deneyin

Bookmark and Share
Tags: , , , ,

Related posts

Java

Comments (0)

Permalink

jboss heap size ayarı

jboss heap size ayarı bin/run.conf dosyasındaki

JAVA_OPTS=

ile başlayan satırdan yapılabilir.

Örnek min. 256m max. 1024m

JAVA_OPTS=”-Xms256m -Xmx1024m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000″

değişikliklerden sonra jboss u kapatıp açmayı unutmayın

windows üzerinde bin/run.conf.bat içerisinden yapılıyor

Bookmark and Share
Tags: , , ,

Related posts

Java

Comments (0)

Permalink

Caused by: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Log4JCategoryLog does not implement Log

Caused by: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Log4JCategoryLog does not implement Log

şeklinde bir hata alıyorsanız muhtemel sebebi proje dizininizde veya classpath içerisinde birden fazla commons-logging jar mevcuttur.

Kullanmadığınızı silin veya başka bir yere taşıyın.

Bookmark and Share
Tags: , ,

Related posts

Java

Comments (0)

Permalink

oracle application server Operation failed with error: org/apache/log4j/Category

Oracle Application Server üzerinde deploy yaparken Operation failed with error: org/apache/log4j/Category şeklinde bir hata alıyorsanız deploy sırasında apache.commons.logging kütüphanesini deploy sırasında classpath ayarlarından kaldırın

Bookmark and Share
Tags: , , , , , ,

Related posts

Java

Comments (0)

Permalink

Switch to our mobile site