Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9192551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:57:05+00:00 2026-06-17T20:57:05+00:00

I have 2 methods: public static Ticket issueTicket(User user,Service service,String[] seats) { Session ticSess=

  • 0

I have 2 methods:

public static Ticket issueTicket(User user,Service service,String[] seats) {
    Session ticSess= DB.factory.openSession();
    ticSess.beginTransaction();
    Date d= new Date();
    Ticket ticket=new Ticket(d, service, user);

    ticSess.save(ticket);
    ticSess.getTransaction().commit();
    int seatCount=seats.length;
    for (int i=0;i<seatCount;i++){
        int seatID=Integer.parseInt(seats[i]);
        Seat seat=getSeatByID(seatID);
        seat.setTicket(ticket);
        ticSess.update(seat);
    }
    return ticket;


}

and,

public static Seat getSeatByID(int seatID) {
    Session proSess = DB.factory.openSession();
    proSess.beginTransaction();
    Seat c = (Seat) (proSess.load(Seat.class, seatID));
    proSess.getTransaction().commit();

    return c;
}

when I call issueTicket method I get:

illegally attempted to associate a proxy with two open Sessions

and If I close the session in getSeatByID method there will be another error telling that the session is closed. Here is the Stack Trace:

at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:164)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:285)
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:185)
at ir.ac.shirazu.cse.Terminal.Seat_$$_javassist_9.setTicket(Seat_$$_javassist_9.java)
at ir.ac.shirazu.cse.Database.DB.issueTicket(DB.java:231)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:57:07+00:00Added an answer on June 17, 2026 at 8:57 pm

    Try closing proSess in getSeatByID() before returning. Currently the Seat indeed remains attached to session opened in getSeatByID().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have async methods that returns an objects public static IEnumerable<Users.User> GetUsers(IEnumerable<string> uids, Field
I have the next 2 methods: public static string[] Method1(CustomObj co) { return new
I have a the following generic methods: public static string Glue(string prefix, string value)
I have two extension methods: public static string ToString(this List<object> list, char delimiter) {
I have the below methods: public static byte[] ConvertFileToBytes(string filePath) { var fInfo =
So these two methods have the same signature but different constraints public static void
All -- I have these two methods in one of my classes: public static
I have the following method: public static T ExecuteScalar<T>( string query, SqlConnection connection, params
I have the following method public static void SerializeToXMLFile(Object obj,Type type, string fileName) {
I have the following method declaration: public static bool SerializeObject<T>(string filename, T objectToSerialize){ I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.