Hi,
FIRSTLY, DONT DISCOURAGE BY the code i put here - u propably don't have to analyze it as the problem should be a common bug , when using POSTGREsql 8.2x
I use newest Postgresql (downloaded today), newest production jdbc driver as well as one build from CVS, and Hibernate 3.2.3
I updated them because I hoped that the problem is resulting from too old libraries.
The mappings rather OK - i can't find any bugs. I just can't put an integer value to some object because the following happens:
PS> Hte important note is that Grupa object (which means Group in english) is inserted to database, but Student fails to insert...
Quote:
org.hibernate.exception.SQLGrammarException: could not insert: [hib.paczka.gen.Student]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2263)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2656)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:52)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at hib.paczka.JUnitTest.testHibernate(JUnitTest.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:228)
at junit.framework.TestSuite.run(TestSuite.java:223)
at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.postgresql.util.PSQLException: ERROR: column "id_rok" is of type integer but expression is of type character varying
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1548)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1316)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:191)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:351)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:305)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2243)
... 30 more
DATABASE:
Code:
-- Table: grupa
-- DROP TABLE grupa;
CREATE TABLE grupa
(
[b]id_rok int4 NOT NULL DEFAULT 0,[/b]
nazwa_g varchar(30) NOT NULL DEFAULT ''::character varying,
objectid numeric NOT NULL,
nr char(40) NOT NULL,
CONSTRAINT pk_grupa PRIMARY KEY (id_rok, nr)
)
WITHOUT OIDS;
ALTER TABLE grupa OWNER TO root;
Code:
CREATE TABLE student
(
pesel_s varchar(30) NOT NULL DEFAULT '0'::character varying,
imie varchar(20) NOT NULL DEFAULT ''::character varying,
nazwisko varchar(30) NOT NULL DEFAULT ''::character varying,
data_ur date NOT NULL DEFAULT '1900-01-01'::date,
adres varchar(50) NOT NULL DEFAULT ''::character varying,
miasto varchar(30) NOT NULL DEFAULT ''::character varying,
kod varchar(6) NOT NULL DEFAULT ''::character varying,
wojewodztwo varchar(30) NOT NULL DEFAULT ''::character varying,
objectid numeric NOT NULL,
nr char(40) NOT NULL,
[b] id_rok int4 NOT NULL,[/b]
CONSTRAINT pk_student PRIMARY KEY (objectid),
CONSTRAINT grupa_student FOREIGN KEY (nr, id_rok)
REFERENCES grupa (nr, id_rok) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT tuc_student_1 UNIQUE (pesel_s)
)
WITHOUT OIDS;
The mappin files:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.2
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="hib.paczka.gen.Student"
table="student"
lazy="false"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="student"
</meta>
<id
name="objectid"
type="java.lang.Long"
column="objectid"
>
<meta attribute="field-description">
@hibernate.id
generator-class="assigned"
type="java.lang.Long"
column="objectid"
</meta>
<generator class="assigned" />
</id>
<property
name="peselS"
type="java.lang.String"
column="pesel_s"
not-null="true"
unique="true"
length="30"
>
<meta attribute="field-description">
@hibernate.property
column="pesel_s"
unique="true"
length="30"
not-null="true"
</meta>
</property>
<property
name="imie"
type="java.lang.String"
column="imie"
not-null="true"
length="20"
>
<meta attribute="field-description">
@hibernate.property
column="imie"
length="20"
not-null="true"
</meta>
</property>
<property
name="nazwisko"
type="java.lang.String"
column="nazwisko"
not-null="true"
length="30"
>
<meta attribute="field-description">
@hibernate.property
column="nazwisko"
length="30"
not-null="true"
</meta>
</property>
<property
name="dataUr"
type="java.sql.Date"
column="data_ur"
not-null="true"
length="13"
>
<meta attribute="field-description">
@hibernate.property
column="data_ur"
length="13"
not-null="true"
</meta>
</property>
<property
name="adres"
type="java.lang.String"
column="adres"
not-null="true"
length="50"
>
<meta attribute="field-description">
@hibernate.property
column="adres"
length="50"
not-null="true"
</meta>
</property>
<property
name="miasto"
type="java.lang.String"
column="miasto"
not-null="true"
length="30"
>
<meta attribute="field-description">
@hibernate.property
column="miasto"
length="30"
not-null="true"
</meta>
</property>
<property
name="kod"
type="java.lang.String"
column="kod"
not-null="true"
length="6"
>
<meta attribute="field-description">
@hibernate.property
column="kod"
length="6"
not-null="true"
</meta>
</property>
<property
name="wojewodztwo"
type="java.lang.String"
column="wojewodztwo"
not-null="true"
length="30"
>
<meta attribute="field-description">
@hibernate.property
column="wojewodztwo"
length="30"
not-null="true"
</meta>
</property>
<!-- Associations -->
<!-- bi-directional many-to-one association to Grupa -->
<many-to-one
name="grupa"
class="hib.paczka.gen.Grupa"
not-null="true"
>
<meta attribute="field-description">
@hibernate.many-to-one
not-null="true"
@hibernate.column name="nr"
@hibernate.column name="id_rok"
</meta>
<column name="nr" />
<column name="id_rok" />
</many-to-one>
<!-- bi-directional one-to-many association to StudentZaliczenie -->
<set
name="studentZaliczenies"
lazy="true"
inverse="true"
cascade="none"
>
<meta attribute="field-description">
@hibernate.set
lazy="true"
inverse="true"
cascade="none"
@hibernate.collection-key
column="student"
@hibernate.collection-one-to-many
class="hib.paczka.gen.StudentZaliczenie"
</meta>
<key>
<column name="student" />
</key>
<one-to-many
class="hib.paczka.gen.StudentZaliczenie"
/>
</set>
</class>
</hibernate-mapping>
[code]
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.2
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="hib.paczka.gen.Grupa"
table="grupa"
lazy="false"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="grupa"
</meta>
<composite-id name="comp_id" class="hib.paczka.gen.GrupaPK">
<meta attribute="field-description" inherit="false">
@hibernate.id
generator-class="assigned"
</meta>
<key-property
name="idRok"
column="id_rok"
type="int"
length="10"
>
<meta attribute="field-description">
@hibernate.property
column="id_rok"
</meta>
</key-property>
<key-property
name="nr"
column="nr"
type="java.lang.String"
length="40"
>
<meta attribute="field-description">
@hibernate.property
column="nr"
</meta>
</key-property>
</composite-id>
<property
name="nazwaG"
type="java.lang.String"
column="nazwa_g"
not-null="true"
length="30"
>
<meta attribute="field-description">
@hibernate.property
column="nazwa_g"
length="30"
not-null="true"
</meta>
</property>
<property
name="objectid"
type="java.math.BigDecimal"
column="objectid"
not-null="true"
length="131089"
>
<meta attribute="field-description">
@hibernate.property
column="objectid"
length="131089"
not-null="true"
</meta>
</property>
<!-- Associations -->
<!-- derived association(s) for compound key -->
<!-- end of derived association(s) -->
<!-- bi-directional one-to-many association to GrupaPrzedmiot -->
<set
name="grupaPrzedmiots"
lazy="true"
inverse="true"
cascade="none"
>
<meta attribute="field-description">
@hibernate.set
lazy="true"
inverse="true"
cascade="none"
@hibernate.collection-key
column="nr"
@hibernate.collection-key
column="id_rok"
@hibernate.collection-one-to-many
class="hib.paczka.gen.GrupaPrzedmiot"
</meta>
<key>
<column name="nr" />
<column name="id_rok" />
</key>
<one-to-many
class="hib.paczka.gen.GrupaPrzedmiot"
/>
</set>
<!-- bi-directional one-to-many association to Uczy -->
<set
name="uczies"
lazy="true"
inverse="true"
cascade="none"
>
<meta attribute="field-description">
@hibernate.set
lazy="true"
inverse="true"
cascade="none"
@hibernate.collection-key
column="nr"
@hibernate.collection-key
column="id_rok"
@hibernate.collection-one-to-many
class="hib.paczka.gen.Uczy"
</meta>
<key>
<column name="nr" />
<column name="id_rok" />
</key>
<one-to-many
class="hib.paczka.gen.Uczy"
/>
</set>
<!-- bi-directional one-to-many association to Student -->
<set
name="students"
lazy="true"
inverse="true"
cascade="none"
>
<meta attribute="field-description">
@hibernate.set
lazy="true"
inverse="true"
cascade="none"
@hibernate.collection-key
column="nr"
@hibernate.collection-key
column="id_rok"
@hibernate.collection-one-to-many
class="hib.paczka.gen.Student"
</meta>
<key>
<column name="nr" />
<column name="id_rok" />
</key>
<one-to-many
class="hib.paczka.gen.Student"
/>
</set>
</class>
</hibernate-mapping>
[/code]
The java files:
Code:
package hib.paczka.gen;
// Generated 2007-04-08 16:33:04 by Hibernate Tools 3.2.0.beta8
import java.sql.Date;
import java.util.HashSet;
import java.util.Set;
/**
* @hibernate.class
* table="student"
*
*/
public class Student implements java.io.Serializable {
// Fields
/**
* @hibernate.id
* generator-class="assigned"
* type="java.lang.Long"
* column="objectid"
*
*/
private Long objectid;
/**
* @hibernate.property
* column="pesel_s"
* unique="true"
* length="30"
* not-null="true"
*
*/
private String peselS;
/**
* @hibernate.property
* column="imie"
* length="20"
* not-null="true"
*
*/
private String imie;
/**
* @hibernate.property
* column="nazwisko"
* length="30"
* not-null="true"
*
*/
private String nazwisko;
/**
* @hibernate.property
* column="data_ur"
* length="13"
* not-null="true"
*
*/
private Date dataUr;
/**
* @hibernate.property
* column="adres"
* length="50"
* not-null="true"
*
*/
private String adres;
/**
* @hibernate.property
* column="miasto"
* length="30"
* not-null="true"
*
*/
private String miasto;
/**
* @hibernate.property
* column="kod"
* length="6"
* not-null="true"
*
*/
private String kod;
/**
* @hibernate.property
* column="wojewodztwo"
* length="30"
* not-null="true"
*
*/
private String wojewodztwo;
/**
* @hibernate.many-to-one
* not-null="true"
* @hibernate.column name="nr"
* @hibernate.column name="id_rok"
*
*/
private Grupa grupa;
/**
* @hibernate.set
* lazy="true"
* inverse="true"
* cascade="none"
* @hibernate.collection-key
* column="student"
* @hibernate.collection-one-to-many
* class="hib.paczka.gen.StudentZaliczenie"
*
*/
private Set studentZaliczenies = new HashSet(0);
// Constructors
/** default constructor */
public Student() {
}
/** minimal constructor */
public Student(Long objectid, String peselS, String imie, String nazwisko, Date dataUr, String adres, String miasto, String kod, String wojewodztwo) {
this.objectid = objectid;
this.peselS = peselS;
this.imie = imie;
this.nazwisko = nazwisko;
this.dataUr = dataUr;
this.adres = adres;
this.miasto = miasto;
this.kod = kod;
this.wojewodztwo = wojewodztwo;
}
/** full constructor */
public Student(Long objectid, String peselS, String imie, String nazwisko, Date dataUr, String adres, String miasto, String kod, String wojewodztwo, Grupa grupa, Set studentZaliczenies) {
this.objectid = objectid;
this.peselS = peselS;
this.imie = imie;
this.nazwisko = nazwisko;
this.dataUr = dataUr;
this.adres = adres;
this.miasto = miasto;
this.kod = kod;
this.wojewodztwo = wojewodztwo;
this.grupa = grupa;
this.studentZaliczenies = studentZaliczenies;
}
// Property accessors
/**
* * @hibernate.id
* generator-class="assigned"
* type="java.lang.Long"
* column="objectid"
*
*/
public Long getObjectid() {
return this.objectid;
}
public void setObjectid(Long objectid) {
this.objectid = objectid;
}
/**
* * @hibernate.property
* column="pesel_s"
* unique="true"
* length="30"
* not-null="true"
*
*/
public String getPeselS() {
return this.peselS;
}
public void setPeselS(String peselS) {
this.peselS = peselS;
}
/**
* * @hibernate.property
* column="imie"
* length="20"
* not-null="true"
*
*/
public String getImie() {
return this.imie;
}
public void setImie(String imie) {
this.imie = imie;
}
/**
* * @hibernate.property
* column="nazwisko"
* length="30"
* not-null="true"
*
*/
public String getNazwisko() {
return this.nazwisko;
}
public void setNazwisko(String nazwisko) {
this.nazwisko = nazwisko;
}
/**
* * @hibernate.property
* column="data_ur"
* length="13"
* not-null="true"
*
*/
public Date getDataUr() {
return this.dataUr;
}
public void setDataUr(Date dataUr) {
this.dataUr = dataUr;
}
/**
* * @hibernate.property
* column="adres"
* length="50"
* not-null="true"
*
*/
public String getAdres() {
return this.adres;
}
public void setAdres(String adres) {
this.adres = adres;
}
/**
* * @hibernate.property
* column="miasto"
* length="30"
* not-null="true"
*
*/
public String getMiasto() {
return this.miasto;
}
public void setMiasto(String miasto) {
this.miasto = miasto;
}
/**
* * @hibernate.property
* column="kod"
* length="6"
* not-null="true"
*
*/
public String getKod() {
return this.kod;
}
public void setKod(String kod) {
this.kod = kod;
}
/**
* * @hibernate.property
* column="wojewodztwo"
* length="30"
* not-null="true"
*
*/
public String getWojewodztwo() {
return this.wojewodztwo;
}
public void setWojewodztwo(String wojewodztwo) {
this.wojewodztwo = wojewodztwo;
}
/**
* * @hibernate.many-to-one
* not-null="true"
* @hibernate.column name="nr"
* @hibernate.column name="id_rok"
*
*/
public Grupa getGrupa() {
return this.grupa;
}
public void setGrupa(Grupa grupa) {
this.grupa = grupa;
}
/**
* * @hibernate.set
* lazy="true"
* inverse="true"
* cascade="none"
* @hibernate.collection-key
* column="student"
* @hibernate.collection-one-to-many
* class="hib.paczka.gen.StudentZaliczenie"
*
*/
public Set getStudentZaliczenies() {
return this.studentZaliczenies;
}
public void setStudentZaliczenies(Set studentZaliczenies) {
this.studentZaliczenies = studentZaliczenies;
}
}
Code:
package hib.paczka.gen;
// Generated 2007-04-08 16:33:04 by Hibernate Tools 3.2.0.beta8
import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Set;
/**
* @hibernate.class
* table="grupa"
*
*/
public class Grupa implements java.io.Serializable {
// Fields
/**
* @hibernate.id
* generator-class="assigned"
*
*/
private GrupaPK comp_id;
/**
* @hibernate.property
* column="nazwa_g"
* length="30"
* not-null="true"
*
*/
private String nazwaG;
/**
* @hibernate.property
* column="objectid"
* length="131089"
* not-null="true"
*
*/
private BigDecimal objectid;
/**
* @hibernate.set
* lazy="true"
* inverse="true"
* cascade="none"
* @hibernate.collection-key
* column="nr"
* @hibernate.collection-key
* column="id_rok"
* @hibernate.collection-one-to-many
* class="hib.paczka.gen.GrupaPrzedmiot"
*
*/
private Set grupaPrzedmiots = new HashSet(0);
/**
* @hibernate.set
* lazy="true"
* inverse="true"
* cascade="none"
* @hibernate.collection-key
* column="nr"
* @hibernate.collection-key
* column="id_rok"
* @hibernate.collection-one-to-many
* class="hib.paczka.gen.Uczy"
*
*/
private Set uczies = new HashSet(0);
/**
* @hibernate.set
* lazy="true"
* inverse="true"
* cascade="none"
* @hibernate.collection-key
* column="nr"
* @hibernate.collection-key
* column="id_rok"
* @hibernate.collection-one-to-many
* class="hib.paczka.gen.Student"
*
*/
private Set students = new HashSet(0);
// Constructors
/** default constructor */
public Grupa() {
}
/** minimal constructor */
public Grupa(GrupaPK comp_id, String nazwaG, BigDecimal objectid) {
this.comp_id = comp_id;
this.nazwaG = nazwaG;
this.objectid = objectid;
}
/** full constructor */
public Grupa(GrupaPK comp_id, String nazwaG, BigDecimal objectid, Set grupaPrzedmiots, Set uczies, Set students) {
this.comp_id = comp_id;
this.nazwaG = nazwaG;
this.objectid = objectid;
this.grupaPrzedmiots = grupaPrzedmiots;
this.uczies = uczies;
this.students = students;
}
// Property accessors
/**
* * @hibernate.id
* generator-class="assigned"
*
*/
public GrupaPK getComp_id() {
return this.comp_id;
}
public void setComp_id(GrupaPK comp_id) {
this.comp_id = comp_id;
}
/**
* * @hibernate.property
* column="nazwa_g"
* length="30"
* not-null="true"
*
*/
public String getNazwaG() {
return this.nazwaG;
}
public void setNazwaG(String nazwaG) {
this.nazwaG = nazwaG;
}
/**
* * @hibernate.property
* column="objectid"
* length="131089"
* not-null="true"
*
*/
public BigDecimal getObjectid() {
return this.objectid;
}
public void setObjectid(BigDecimal objectid) {
this.objectid = objectid;
}
/**
* * @hibernate.set
* lazy="true"
* inverse="true"
* cascade="none"
* @hibernate.collection-key
* column="nr"
* @hibernate.collection-key
* column="id_rok"
* @hibernate.collection-one-to-many
* class="hib.paczka.gen.GrupaPrzedmiot"
*
*/
public Set getGrupaPrzedmiots() {
return this.grupaPrzedmiots;
}
public void setGrupaPrzedmiots(Set grupaPrzedmiots) {
this.grupaPrzedmiots = grupaPrzedmiots;
}
/**
* * @hibernate.set
* lazy="true"
* inverse="true"
* cascade="none"
* @hibernate.collection-key
* column="nr"
* @hibernate.collection-key
* column="id_rok"
* @hibernate.collection-one-to-many
* class="hib.paczka.gen.Uczy"
*
*/
public Set getUczies() {
return this.uczies;
}
public void setUczies(Set uczies) {
this.uczies = uczies;
}
/**
* * @hibernate.set
* lazy="true"
* inverse="true"
* cascade="none"
* @hibernate.collection-key
* column="nr"
* @hibernate.collection-key
* column="id_rok"
* @hibernate.collection-one-to-many
* class="hib.paczka.gen.Student"
*
*/
public Set getStudents() {
return this.students;
}
public void setStudents(Set students) {
this.students = students;
}
}
Code:
package hib.paczka.gen;
// Generated 2007-04-08 16:33:04 by Hibernate Tools 3.2.0.beta8
/**
* GrupaPK generated by hib.paczka.gen2java
*/
public class GrupaPK implements java.io.Serializable {
// Fields
/**
* @hibernate.property
* column="id_rok"
*
*/
private int idRok;
/**
* @hibernate.property
* column="nr"
*
*/
private String nr;
// Constructors
/** default constructor */
public GrupaPK() {
}
/** full constructor */
public GrupaPK(int idRok, String nr) {
this.idRok = idRok;
this.nr = nr;
}
// Property accessors
/**
* * @hibernate.property
* column="id_rok"
*
*/
public int getIdRok() {
return this.idRok;
}
public void setIdRok(int idRok) {
this.idRok = idRok;
}
/**
* * @hibernate.property
* column="nr"
*
*/
public String getNr() {
return this.nr;
}
public void setNr(String nr) {
this.nr = nr;
}
}
TEST JUNIT:
Code:
package hib.paczka;
import hib.paczka.gen.Grupa;
import hib.paczka.gen.GrupaPK;
import hib.paczka.gen.Student;
import java.math.BigDecimal;
import java.sql.Types;
import java.util.Calendar;
import junit.framework.TestCase;
import org.hibernate.Session;
public class JUnitTest extends TestCase {
public void testHibernate() {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Grupa g = new Grupa();
g.setNazwaG("");
g.setNazwaG("");
g.setObjectid(new BigDecimal(1));
GrupaPK comp_id = new GrupaPK();
comp_id.setIdRok(new Integer(46));
//setObject(1,"123",Types.INTEGER)')
comp_id.setNr(new String("2"));
g.setComp_id(comp_id);
//g.s
session.save(g);
session.getTransaction().commit();
Session session2 = HibernateUtil.getSessionFactory().getCurrentSession();
session2.beginTransaction();
Calendar cal = Calendar.getInstance();
Student st=new Student();
st.setAdres("");
st.setDataUr(new java.sql.Date(cal.getTime().getTime()));
st.setGrupa(g);
st.setImie("");
st.setKod("");
st.setMiasto("");
st.setNazwisko("");
st.setObjectid(new Long(38));
st.setPeselS("");
st.setWojewodztwo("");
session2.save(st);
session2.getTransaction().commit();
}
}