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 6790075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:40:55+00:00 2026-05-26T17:40:55+00:00

I have two models: User and Base. User model: http://pastebin.com/WdLzBkHJ Base model: http://pastebin.com/tQrEUaSu At

  • 0

I have two models: User and Base.

User model:
http://pastebin.com/WdLzBkHJ

Base model:
http://pastebin.com/tQrEUaSu

At first I want to put your mind on this notation in Base model:

@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true)

It doesn’t work (in SQL Debug shown that Hibernate generated queries with using unnecessary columns which in MySQL are configured as nullable). Tell me please why? What am I doing wrong?

And the main problem is there (method in which user uploads base and string in this base inserts in the MySQL table after parsing):
http://pastebin.com/yG3Mapze

Insertation is VERY SLOW. I have file with 70000 string per line and I can’t wait until Hibernate insert this string into DB. Maximum I was waiting for 30 minutes and that wasn’t the end.
If I’ll use raw queries like that:

DB.execute("INSERT INTO bases (user_id,email,password) VALUES (1,'" + email.replaceAll("'", "\'") + "','" + password.replaceAll("'", "\'") + "')");

instead of

b.save();

After that insertation of 70000 strings to DB completes after ~10-20 seconds.
So I can’t understand where is the problem and how to fix it?

Also you can see this code above method declaration:

@NoTransaction

If I uncomment it then I’ll recieve this exception:

@689mbad1k
Internal Server Error (500) for request POST /checker/uploadnewbase

JPA error
A JPA error occurred (The JPA context is not initialized. JPA Entity Manager automatically start when one or more classes annotated with the @javax.persistence.Entity annotation are found in the application.):

play.exceptions.JPAException: The JPA context is not initialized. JPA Entity Manager automatically start when one or more classes annotated with the @javax.persistence.Entity annotation are found in the application.
at play.db.jpa.JPA.get(JPA.java:22)
at play.db.jpa.JPA.em(JPA.java:51)
at play.db.jpa.JPQL.em(JPQL.java:16)
at play.db.jpa.JPQL.find(JPQL.java:44)
at models.User.find(User.java)
at controllers.Security.getUser(Security.java:30)
at controllers.GlobalController.userStat(GlobalController.java:21)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:502)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:476)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:471)
at play.mvc.ActionInvoker.handleBefores(ActionInvoker.java:320)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:140)
at Invocation.HTTP Request(Play!)

But in Play manual we can see that:
“If you want to prevent Play from starting any transaction at all, you can annotate the method with @play.db.jpa.NoTransaction.

To prevent transactions for all methods, you can annotate the Controller-class with @play.db.jpa.NoTransaction.”

So I have three problems which I described:

  1. About exception in NoTransaction.
  2. About using dynamicInsert = true.
  3. About improving perfomance for Hibernate like if I’ll use raw queries.
  • 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-05-26T17:40:56+00:00Added an answer on May 26, 2026 at 5:40 pm

    The problem is the hibernate session, which must be cleared. Otherwise you get problems with memory and performance. You can found some information in http://docs.jboss.org/hibernate/core/3.3/reference/en/html/batch.html. Unfortunately I don’t know how to get the HibernateSession. Perhaps you can get the EntityManager and work with it. But my experiences with Hibernate and Batch are really frustrating, so I would recommend to use your raw-solution.

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

Sidebar

Related Questions

I have a two models set up like this: class User < ActiveRecord::Base #
Suppose you have two models, User and City, joined by a third model CityPermission:
I have two models, Article and Post that both inherit from a base model
Let's say I have two models like so: class Comment < ActiveRecord::Base belongs_to :user
Let's say I have two models like so: class Comment < ActiveRecord::Base belongs_to :user
so I have two models: class User < ActiveRecord::Base has_and_belongs_to_many :followed_courses, :class_name => Course
I have two models with a one-to-one association. class User < ActiveRecord::Base has_one :setting
I have two models class User < ActiveRecord::Base has_many :requests, :foreign_key => :recipient_id .
I have two models -- User and Entry -- that are related through a
I have two models: class User end class Message belongs_to :sender, :class_name=> 'User' belongs_to

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.