-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 posts ] 
Author Message
 Post subject: Can anyone help me in this:
PostPosted: Fri Sep 23, 2005 8:00 am 
Newbie

Joined: Tue Jun 07, 2005 6:54 am
Posts: 17
Hi,

Can anyone help me in this:

2)
How do i deal with the associations of the following table structure(postgres) in mapping files & their POJOs & DAOs:-

CREATE TABLE member
(
member_id serial NOT NULL,
member_role_id int4 NOT NULL,
username varchar(50) NOT NULL,
passwd varchar(50) NOT NULL,
first_name varchar(50) NOT NULL,
last_name varchar(50),
email varchar(50),
active char(1),
last_login_dt timestamp,
last_logout_dt timestamp,
admin_flag char(1) NOT NULL DEFAULT 'N'::bpchar,
CONSTRAINT member_pk PRIMARY KEY (member_id),
CONSTRAINT member_role_member_fk1 FOREIGN KEY (member_role_id) REFERENCES member_role (member_role_id) ON UPDATE NO ACTION ON DELETE NO ACTION
)


CREATE TABLE member_role
(
member_role_id serial NOT NULL,
member_role varchar(20) NOT NULL,
member_role_desc varchar(50),
CONSTRAINT member_role_pk PRIMARY KEY (member_role_id)
)


CREATE TABLE team
(
team_id serial NOT NULL,
team_desc varchar(50) NOT NULL,
CONSTRAINT team_pk PRIMARY KEY (team_id)
)


CREATE TABLE team_member
(
team_member_id serial NOT NULL,
team_id int4 NOT NULL,
member_id int4 NOT NULL,
member_role_id int4 NOT NULL,
start_dt timestamp NOT NULL DEFAULT ('now'::text)::date,
end_dt timestamp,
CONSTRAINT team_member_pk PRIMARY KEY (team_member_id),
CONSTRAINT member_role_team_member_fk1 FOREIGN KEY (member_role_id) REFERENCES member_role (member_role_id) ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT member_team_member_fk1 FOREIGN KEY (member_id) REFERENCES member (member_id) ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT team_team_member_fk1 FOREIGN KEY (team_id) REFERENCES team (team_id) ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT team_member_uq001 UNIQUE (team_id, member_id, member_role_id, start_dt)
)


Kindly help on both the above problems.It is very urgent.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 23, 2005 8:32 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
To start you can use hibernate tools to revers engineer your database into mapping files

_________________
Seb
(Please don't forget to give credits if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 23, 2005 8:50 am 
Newbie

Joined: Tue Jun 07, 2005 6:54 am
Posts: 17
Hi,

already tried that.not working.how can i add or update data into the join table.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 23, 2005 9:01 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
Please be more precise : why is it not working.

Don't think people can help you create your mapping files from scratch. To start read the doc, download the caveat emptor example, find some tutorials on the wiki and go on. Then if you have some problems post it to the forum

_________________
Seb
(Please don't forget to give credits if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 23, 2005 9:37 am 
Newbie

Joined: Tue Jun 07, 2005 6:54 am
Posts: 17
Hi,

My dear friend.I wouldn't even come to forum until i have tried it myself first.First I had tried and then posted in forum.I will show you the code i have written.



<class name="TeamMember" table="team_member">


<composite-id>
<key-many-to-one name="member" column="member_id" class="Member" />
<key-many-to-one name="memberRole" column="member_role_id" class="MemberRole" />
<key-many-to-one name="team" column="team_id" class="Team" />
<key-property name="startDt" column="start_dt" type="java.util.Calendar"/>
</composite-id>


<property name="endDt" column="end_dt" type="java.util.Date" />

</class>



<class name="Member" table="member">
<id name="memberId" column="member_id" type="java.lang.Integer">
<generator class="sequence"/>
</id>

<property name="memberRoleId" column="member_role_id" type="java.lang.Integer" not-null="true" />
<property name="username" column="username" type="java.lang.String" not-null="true" />
<property name="passwd" column="passwd" type="java.lang.String" not-null="true" />
<property name="firstName" column="first_name" type="java.lang.String" not-null="true" />
<property name="lastName" column="last_name" type="java.lang.String" />
<property name="email" column="email" type="java.lang.String" />
<property name="active" column="active" type="java.lang.String" />
<property name="lastLoginDt" column="last_login_dt" type="java.util.Date" />
<property name="lastLogoutDt" column="last_logout_dt" type="java.util.Date" />
<property name="adminFlag" column="admin_flag" type="java.lang.String" not-null="true" />

<set name="TM" inverse="true" cascade="all">
<key column="member_id">

</key>
<one-to-many class="TeamMember"/>
</set>

</class>


<class name="MemberRole" table="member_role">
<id name="memberRoleId" column="member_role_id" type="java.lang.Integer">
<generator class="sequence"/>
</id>

<property name="memberRole" column="member_role" type="java.lang.String" not-null="true" />
<property name="memberRoleDesc" column="member_role_desc" type="java.lang.String" />

<set name="TM" inverse="true" cascade="all">
<key column="member_role_id">

</key>
<one-to-many class="TeamMember"/>
</set>

</class>


<class name="Team" table="team">
<id name="teamId" column="team_id" type="java.lang.Integer">
<generator class="sequence"/>
</id>

<property name="teamDesc" column="team_desc" type="java.lang.String" not-null="true" />

<set name="TM" inverse="true" cascade="all">
<key column="team_id">

</key>
<one-to-many class="TeamMember"/>
</set>

</class>


Now for the classes.

public abstract class Member implements Serializable
{
/** The cached hash code value for this instance. Settting to 0 triggers re-calculation. */
private int hashValue = 0;

/** The composite primary key value. */
private java.lang.Integer memberId;

/** The value of the simple memberRoleId property. */
private java.lang.Integer memberRoleId;

/** The value of the simple username property. */
private java.lang.String username;

/** The value of the simple passwd property. */
private java.lang.String passwd;

/** The value of the simple firstName property. */
private java.lang.String firstName;

/** The value of the simple lastName property. */
private java.lang.String lastName;

/** The value of the simple email property. */
private java.lang.String email;

/** The value of the simple active property. */
private java.lang.String active;

/** The value of the simple lastLoginDt property. */
private java.util.Date lastLoginDt;

/** The value of the simple lastLogoutDt property. */
private java.util.Date lastLogoutDt;

/** The value of the simple adminFlag property. */
private java.lang.String adminFlag;

private Set TM = new HashSet();

// Their getters & setters.

}


public abstract class MemberRole
implements Serializable
{
/** The cached hash code value for this instance. Settting to 0 triggers re-calculation. */
private int hashValue = 0;

/** The composite primary key value. */
private java.lang.Integer memberRoleId;

/** The value of the simple memberRole property. */
private java.lang.String memberRole;

/** The value of the simple memberRoleDesc property. */
private java.lang.String memberRoleDesc;


private Set TM = new HashSet();

// getter & setter

}


public abstract class Team
implements Serializable
{
/** The cached hash code value for this instance. Settting to 0 triggers re-calculation. */
private int hashValue = 0;

/** The composite primary key value. */
private java.lang.Integer teamId;

/** The value of the simple teamDesc property. */
private java.lang.String teamDesc;

private Set TM = new HashSet();

// getter & setter
}


public abstract class AbstractTeamMember
implements Serializable
{
/** The cached hash code value for this instance. Settting to 0 triggers re-calculation. */
private int hashValue = 0;

/** The composite primary key value. */
private java.lang.Integer teamMemberId;

/** The value of the member association. */
private Member member;

/** The value of the memberRole association. */
private MemberRole memberRole;

/** The value of the team association. */
private Team team;

/** The value of the simple startDt property. */
private Calendar startDt;

/** The value of the simple endDt property. */
private java.util.Date endDt;

// getter & setter
}



And finally the DAO.

public class testAsso
{
public static void main(String[] args) throws Exception
{

//IBOSession session = null;
TeamMember objTeamMember = new TeamMember();

try
{
Session session=HibernateUtil.currentSession();
Member memberObj = null;
Calendar xmas = new GregorianCalendar(1998, Calendar.DECEMBER, 25);
Date date = xmas.getTime();
//session = ((BOSession)session).currentHibernateSession();

Member member = (Member)session.load(Member.class, new Integer(100));
Team team = (Team)session.load(Team.class, new Integer(40));
MemberRole memberrole = (MemberRole)session.load(MemberRole.class, new Integer(30));


Set s = new HashSet();


objTeamMember.setMember(member);
objTeamMember.setTeam(team);
objTeamMember.setMemberRole(memberrole);
objTeamMember.setStartDt(xmas);
objTeamMember.setEndDt(date);

member.setMemberRoleId(memberrole.getMemberRoleId());

s.add(objTeamMember);
member.setTM(s);


session.save(objTeamMember);
session.save(member);
//session.merge(objTeamMember);


session.flush();


TeamMember objTMember=null;
Query lst = session.createQuery("Select tm from TeamMember tm Where tm.member=100");
List lstMembers=lst.list();

if(lstMembers.size() !=0)
{
int cnt=1;
for(Iterator iter=lstMembers.iterator();iter.hasNext();)
{
objTMember=(TeamMember)iter.next();
System.out.println("Member : "+ cnt + " "+objTMember.getMember().getMemberId());
System.out.println("Team : "+ cnt + " "+objTMember.getTeam().getTeamId());
System.out.println("MemberRole : "+ cnt + " "+objTMember.getMemberRole().getMemberRoleId());
cnt = cnt+1;
}
}

session.close();


}
catch (Exception e)
{
System.out.println("submitTo() : Exception while submiting " + e.getMessage()+" : " +e.getCause()+" - " +e.fillInStackTrace());
//session.rollback();
throw e;
}
finally
{
try
{
//session.closeSession();
}
catch (Exception e)
{
System.out.println("Exception occured during closing of the session: " + e.getMessage());
throw e;
}

}

}
}


Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 23, 2005 9:46 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
But I don't understand what's your problem. Do you have any exception ? Is it the behaviour that is not like you want ?

First of all, when reading at your mapping files, you are using key-many-to-one. Hibernate team suggest in the doc to use key-property with many-to-one update=false insert=false. Better than that, you can use a surrogate key in your TeamMember, maybe it will solve the problem you have

_________________
Seb
(Please don't forget to give credits if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 23, 2005 9:57 am 
Newbie

Joined: Tue Jun 07, 2005 6:54 am
Posts: 17
When i run the code.It shows no exception but data does not gets stored into database.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 23, 2005 10:03 am 
Newbie

Joined: Tue Jun 07, 2005 6:54 am
Posts: 17
raj_raj wrote:
When i run the code.It shows no exception but data does not gets stored into database.I want to store the data in the join table i.e. TeamMember & memberRoleId column in member table.Nothing is getting saved.


Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 23, 2005 10:04 am 
Senior
Senior

Joined: Thu Aug 04, 2005 4:54 am
Posts: 153
Location: Birmingham, UK
Set you logging level to debug and post the complete log.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 23, 2005 10:15 am 
Newbie

Joined: Tue Jun 07, 2005 6:54 am
Posts: 17
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Hibernate: select member0_.member_id as member1_0_, member0_.member_role_id as member2_0_0_, member0_.username as username0_0_, member0_.passwd as passwd0_0_, member0_.first_name as first5_0_0_, member0_.last_name as last6_0_0_, member0_.email as email0_0_, member0_.active as active0_0_, member0_.last_login_dt as last9_0_0_, member0_.last_logout_dt as last10_0_0_, member0_.admin_flag as admin11_0_0_ from member member0_ where member0_.member_id=?
A : CE #1
Hibernate: select team0_.team_id as team1_0_, team0_.team_desc as team2_3_0_ from team team0_ where team0_.team_id=?
B : Team D
Hibernate: select memberrole0_.member_role_id as member1_0_, memberrole0_.member_role as member2_4_0_, memberrole0_.member_role_desc as member3_4_0_ from member_role memberrole0_ where memberrole0_.member_role_id=?
C : QA
D : 100
E : 40
F : 30
Hibernate: insert into team_member (end_dt, member_id, member_role_id, team_id, start_dt) values (?, ?, ?, ?, ?)
Hibernate: update member set member_role_id=?, username=?, passwd=?, first_name=?, last_name=?, email=?, active=?, last_login_dt=?, last_logout_dt=?, admin_flag=? where member_id=?
Hibernate: select teammember0_.member_id as member1_, teammember0_.member_role_id as member2_, teammember0_.team_id as team3_, teammember0_.start_dt as start4_, teammember0_.end_dt as end5_1_ from team_member teammember0_ where (teammember0_.member_id=100)
Member : 1 100
Team : 1 40
MemberRole : 1 30
Member : 2 100
Team : 2 10
MemberRole : 2 10


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 23, 2005 10:51 am 
Senior
Senior

Joined: Thu Aug 04, 2005 4:54 am
Posts: 153
Location: Birmingham, UK
Quote:
og4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly


Please enable log4j following the instructions in the documentation and turn on full debug level logging.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 10:29 am 
Newbie

Joined: Tue Jun 07, 2005 6:54 am
Posts: 17
hi,

Hibernate: select member0_.member_id as member1_0_, member0_.member_role_id as member2_0_0_, member0_.username as username0_0_, member0_.passwd as passwd0_0_, member0_.first_name as first5_0_0_, member0_.last_name as last6_0_0_, member0_.email as email0_0_, member0_.active as active0_0_, member0_.last_login_dt as last9_0_0_, member0_.last_logout_dt as last10_0_0_, member0_.admin_flag as admin11_0_0_ from member member0_ where member0_.member_id=?
A : CE #1
Hibernate: select team0_.team_id as team1_0_, team0_.team_desc as team2_3_0_ from team team0_ where team0_.team_id=?
B : Team D
Hibernate: select memberrole0_.member_role_id as member1_0_, memberrole0_.member_role as member2_4_0_, memberrole0_.member_role_desc as member3_4_0_ from member_role memberrole0_ where memberrole0_.member_role_id=?
C : QA
D : 100
E : 40
F : 30
Hibernate: insert into team_member (end_dt, member_id, member_role_id, team_id, start_dt) values (?, ?, ?, ?, ?)
Hibernate: update member set member_role_id=?, username=?, passwd=?, first_name=?, last_name=?, email=?, active=?, last_login_dt=?, last_logout_dt=?, admin_flag=? where member_id=?
Hibernate: select teammember0_.member_id as member1_, teammember0_.member_role_id as member2_, teammember0_.team_id as team3_, teammember0_.start_dt as start4_, teammember0_.end_dt as end5_1_ from team_member teammember0_ where (teammember0_.member_id=100)
Member : 100
Team : 40
MemberRole : 30
Member : 100
Team : 10
MemberRole : 10


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 10:37 am 
Senior
Senior

Joined: Thu Aug 04, 2005 4:54 am
Posts: 153
Location: Birmingham, UK
Deleting the line about not turning log4j on and reposting is not the same as turning log4j and posting a debug level log. Sorry, there is no way I can help you with the information provided.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 11:08 am 
Newbie

Joined: Tue Jun 07, 2005 6:54 am
Posts: 17
how do i enable log4j,apart from putting the .jar file in lib folder.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 11:18 am 
Newbie

Joined: Tue Jun 07, 2005 6:54 am
Posts: 17
Hi,

in anyway I wanted to know given the following table structure:-

How do i deal with the associations of the following table structure(postgres) in mapping files & their POJOs & DAOs:-

CREATE TABLE member
(
member_id serial NOT NULL,
member_role_id int4 NOT NULL,
username varchar(50) NOT NULL,
passwd varchar(50) NOT NULL,
first_name varchar(50) NOT NULL,
last_name varchar(50),
email varchar(50),
active char(1),
last_login_dt timestamp,
last_logout_dt timestamp,
admin_flag char(1) NOT NULL DEFAULT 'N'::bpchar,
CONSTRAINT member_pk PRIMARY KEY (member_id),
CONSTRAINT member_role_member_fk1 FOREIGN KEY (member_role_id) REFERENCES member_role (member_role_id) ON UPDATE NO ACTION ON DELETE NO ACTION
)


CREATE TABLE member_role
(
member_role_id serial NOT NULL,
member_role varchar(20) NOT NULL,
member_role_desc varchar(50),
CONSTRAINT member_role_pk PRIMARY KEY (member_role_id)
)


CREATE TABLE team
(
team_id serial NOT NULL,
team_desc varchar(50) NOT NULL,
CONSTRAINT team_pk PRIMARY KEY (team_id)
)


CREATE TABLE team_member
(
team_member_id serial NOT NULL,
team_id int4 NOT NULL,
member_id int4 NOT NULL,
member_role_id int4 NOT NULL,
start_dt timestamp NOT NULL DEFAULT ('now'::text)::date,
end_dt timestamp,
CONSTRAINT team_member_pk PRIMARY KEY (team_member_id),
CONSTRAINT member_role_team_member_fk1 FOREIGN KEY (member_role_id) REFERENCES member_role (member_role_id) ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT member_team_member_fk1 FOREIGN KEY (member_id) REFERENCES member (member_id) ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT team_team_member_fk1 FOREIGN KEY (team_id) REFERENCES team (team_id) ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT team_member_uq001 UNIQUE (team_id, member_id, member_role_id, start_dt)
)


I have written the following code & iam yet not able to save data to member table, join table & other related tables.

<class name="TeamMember" table="team_member">


<composite-id>
<key-many-to-one name="member" column="member_id" class="Member" />
<key-many-to-one name="memberRole" column="member_role_id" class="MemberRole" />
<key-many-to-one name="team" column="team_id" class="Team" />
<key-property name="startDt" column="start_dt" type="java.util.Calendar"/>
</composite-id>


<property name="endDt" column="end_dt" type="java.util.Date" />

</class>



<class name="Member" table="member">
<id name="memberId" column="member_id" type="java.lang.Integer">
<generator class="sequence"/>
</id>

<property name="memberRoleId" column="member_role_id" type="java.lang.Integer" not-null="true" />
<property name="username" column="username" type="java.lang.String" not-null="true" />
<property name="passwd" column="passwd" type="java.lang.String" not-null="true" />
<property name="firstName" column="first_name" type="java.lang.String" not-null="true" />
<property name="lastName" column="last_name" type="java.lang.String" />
<property name="email" column="email" type="java.lang.String" />
<property name="active" column="active" type="java.lang.String" />
<property name="lastLoginDt" column="last_login_dt" type="java.util.Date" />
<property name="lastLogoutDt" column="last_logout_dt" type="java.util.Date" />
<property name="adminFlag" column="admin_flag" type="java.lang.String" not-null="true" />

<set name="TM" inverse="true" cascade="all">
<key column="member_id">

</key>
<one-to-many class="TeamMember"/>
</set>

</class>


<class name="MemberRole" table="member_role">
<id name="memberRoleId" column="member_role_id" type="java.lang.Integer">
<generator class="sequence"/>
</id>

<property name="memberRole" column="member_role" type="java.lang.String" not-null="true" />
<property name="memberRoleDesc" column="member_role_desc" type="java.lang.String" />

<set name="TM" inverse="true" cascade="all">
<key column="member_role_id">

</key>
<one-to-many class="TeamMember"/>
</set>

</class>


<class name="Team" table="team">
<id name="teamId" column="team_id" type="java.lang.Integer">
<generator class="sequence"/>
</id>

<property name="teamDesc" column="team_desc" type="java.lang.String" not-null="true" />

<set name="TM" inverse="true" cascade="all">
<key column="team_id">

</key>
<one-to-many class="TeamMember"/>
</set>

</class>


Now for the classes.

public abstract class Member implements Serializable
{
/** The cached hash code value for this instance. Settting to 0 triggers re-calculation. */
private int hashValue = 0;

/** The composite primary key value. */
private java.lang.Integer memberId;

/** The value of the simple memberRoleId property. */
private java.lang.Integer memberRoleId;

/** The value of the simple username property. */
private java.lang.String username;

/** The value of the simple passwd property. */
private java.lang.String passwd;

/** The value of the simple firstName property. */
private java.lang.String firstName;

/** The value of the simple lastName property. */
private java.lang.String lastName;

/** The value of the simple email property. */
private java.lang.String email;

/** The value of the simple active property. */
private java.lang.String active;

/** The value of the simple lastLoginDt property. */
private java.util.Date lastLoginDt;

/** The value of the simple lastLogoutDt property. */
private java.util.Date lastLogoutDt;

/** The value of the simple adminFlag property. */
private java.lang.String adminFlag;

private Set TM = new HashSet();

// Their getters & setters.

}


public abstract class MemberRole
implements Serializable
{
/** The cached hash code value for this instance. Settting to 0 triggers re-calculation. */
private int hashValue = 0;

/** The composite primary key value. */
private java.lang.Integer memberRoleId;

/** The value of the simple memberRole property. */
private java.lang.String memberRole;

/** The value of the simple memberRoleDesc property. */
private java.lang.String memberRoleDesc;


private Set TM = new HashSet();

// getter & setter

}


public abstract class Team
implements Serializable
{
/** The cached hash code value for this instance. Settting to 0 triggers re-calculation. */
private int hashValue = 0;

/** The composite primary key value. */
private java.lang.Integer teamId;

/** The value of the simple teamDesc property. */
private java.lang.String teamDesc;

private Set TM = new HashSet();

// getter & setter
}


public abstract class AbstractTeamMember
implements Serializable
{
/** The cached hash code value for this instance. Settting to 0 triggers re-calculation. */
private int hashValue = 0;

/** The composite primary key value. */
private java.lang.Integer teamMemberId;

/** The value of the member association. */
private Member member;

/** The value of the memberRole association. */
private MemberRole memberRole;

/** The value of the team association. */
private Team team;

/** The value of the simple startDt property. */
private Calendar startDt;

/** The value of the simple endDt property. */
private java.util.Date endDt;

// getter & setter
}



And finally the DAO.

public class testAsso
{
public static void main(String[] args) throws Exception
{

//IBOSession session = null;
TeamMember objTeamMember = new TeamMember();

try
{
Session session=HibernateUtil.currentSession();
Member memberObj = null;
Calendar xmas = new GregorianCalendar(1998, Calendar.DECEMBER, 25);
Date date = xmas.getTime();
//session = ((BOSession)session).currentHibernateSession();

Member member = (Member)session.load(Member.class, new Integer(100));
Team team = (Team)session.load(Team.class, new Integer(40));
MemberRole memberrole = (MemberRole)session.load(MemberRole.class, new Integer(30));


Set s = new HashSet();


objTeamMember.setMember(member);
objTeamMember.setTeam(team);
objTeamMember.setMemberRole(memberrole);
objTeamMember.setStartDt(xmas);
objTeamMember.setEndDt(date);

member.setMemberRoleId(memberrole.getMemberRoleId());

s.add(objTeamMember);
member.setTM(s);


session.save(objTeamMember);
session.save(member);
//session.merge(objTeamMember);


session.flush();


TeamMember objTMember=null;
Query lst = session.createQuery("Select tm from TeamMember tm Where tm.member=100");
List lstMembers=lst.list();

if(lstMembers.size() !=0)
{
int cnt=1;
for(Iterator iter=lstMembers.iterator();iter.hasNext();)
{
objTMember=(TeamMember)iter.next();
System.out.println("Member : "+ cnt + " "+objTMember.getMember().getMemberId());
System.out.println("Team : "+ cnt + " "+objTMember.getTeam().getTeamId());
System.out.println("MemberRole : "+ cnt + " "+objTMember.getMemberRole().getMemberRoleId());
cnt = cnt+1;
}
}

session.close();


}
catch (Exception e)
{
System.out.println("submitTo() : Exception while submiting " + e.getMessage()+" : " +e.getCause()+" - " +e.fillInStackTrace());
//session.rollback();
throw e;
}
finally
{
try
{
//session.closeSession();
}
catch (Exception e)
{
System.out.println("Exception occured during closing of the session: " + e.getMessage());
throw e;
}

}

}
}

just going through my code to find out where i made mistake is all you experts need to do.

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.