Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I got this Java webapp (JSP+Struts+Hibernate+MySQL+tomcat6) in which there are like 20000 users right now and the number is growing up rapidly. I have to rank all the users periodically. The ranking process involves lots of objects and hibernate actions and it's fairly heavy. Talking java, unfortunately I must iterate on all of the users and apply this procedure in them one by one. this method sucks out lots of the server's resources.
on the other hand I might be able to run all these actions in a stored procedure on the MySQL side. I'm pretty sure the code there will be a complete mess and troublesome to modify later on. although the performance would be much more better this way but software engineering principles wouldn't take this solution nicely.
what do you suggest?
This is obviously much more efficient in SQL. The real problem is that you are using hibernate and so have lost control over your schema which is why a solution like iBatis, although less popular, makes more sense - because it allows you to switch to SQL when that is the more appropriate tool for the job.
Given that you have chosen hibernate, are you sure that you can't push the API it provides into doing this? Have you looked in detail at the criteria API? That includes associations - it might be possible to shoe-horn what you want in there and so keep the logic more closely associated with the classes. http://docs.jboss.org/hibernate/stable/core/reference/en-US/html/querycriteria.html
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm looking for the optimal way to handle the following scenario, preferably some implementation that's already been made for something like this.
There are two Systems (Springboot Webapps) that are supposed to communicate which each other through a Rest-gateway. Transfers shall be handled with Json over HTTP.
1st System is the Project part, 2nd System is the Persons part and they both implement their own persistent sql-database. Both systems depend on each others data and it cannot be expected that both systems are online at all times.
What would be the best way to achieve that both systems data is always up 2 date? Is there any plugin you could recommend to handle the synchronization process which also implements scenarios like one system shutting down while sending or the other way round?
Thanks in advance!
If you can't expect both systems to be online at all times, and you don't want any downtime when one of them is down, I think that the best way to do it is to share a common database. This has some problems of its own and you should think if it's worth, maybe you would be better having two completely independent services which rely on each other and being ready to replicate one of them if it's needed.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I am using JSP/Serverlets for my upcoming web application project. It is high traffic concurrent users web site. There has been many discussion about performance issues of Java 8 and especially in Streams.
Anyone having specific knowledge about performance of streams and whether its advisable to use in High traffic Web Applications so as to not compromise on latency and response time ?
As a general statement, outside of Java 8 Streams, it is pretty much impossible to answer your question as stated because it depends.
If you've got a method that is called hundreds of times per second then you would need to be very careful about performance. You'd want to tune it the best you could. Conversely, if you've got a method that gets called once a day then you likely wouldn't spend too much time optimizing it.
Streams are a useful tool when used correctly and they are easy to abuse. I've seen developers who thought it was a great idea to read an entire database table and use filtering with streams to effectively do a SQL "where" clause. That's a bad design but it honestly wouldn't be seen in the once-a-day method call.
Don't try to make these blanket "this is good or this is bad" statements. Do a good design and use the tools where they are appropriate. Optimize the parts of your application that need it but don't do pre-mature optimizations - you'll never finish the project.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have to admit that I didn't have the luck to use JPA, so If my question will sound weird please don't blame me. AFAIK Hibernate seems to be a wide spread implementation of JPA. The question is: Are there any cases where importing Hibernate can be avoided? My boss said that we haven't to "overhead" our project with external things and could implement the necessary features of JPA ourselves. But almost everybody says that reinventing the wheel is just senseless and recommend to use ready implementations of JPA. Now I'm a bit confused and don't know what is the best way to go.
Depends on the scale of your project: the cost of learning hibernate vs the cost of rolling your own persistence mechanism.
Also worth considering other payoffs: will you be likely to use hibernate in the future? Then the time invested will be worthwhile.
On the other hand it is always good to eliminate 3rd party dependencies where possible. If your problem is small, an external library can often provide an unnecessary layer of indirection when trying to diagnose issues.
More on the topic here: http://www.joelonsoftware.com/articles/fog0000000007.html
It depends on what you actually do with the database. If you mainly work with highly tabular data and you rely much on bulk queries then JPA will not be that useful and if you have no prior experience it will be hard to use it effectively.
If on the other hand you are manipulation complex object structures that need to be persisted then JPA is very useful.
Note that Hibernate is not the only JPA provider. So maybe your boss would be happier with for instance EclipseLink as this is the reference implentation.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have many kinds of db, some are oracle and some are MySQL ,
so when i have an operation about transaction , how can i know which db should be operated.
Have the ways to encapsulate for them to ensure the correct operation ?
what should i do to route these transaction to the correct db ? Do you have any ideas?
Database portability is a great goal to aim for, and is fully achievable for standard & even moderately complex business applications.
Practically, there are two main issues:
1) Some databases (Oracle) have non-standard DDL, especially data-types. This can be converted easily, with search-and-replace.
2) ID/ primary key generation has to be portable; this rules out sequences & auto-generated columns. Use an allocator table instead, which can be completely portable as well as significantly more performant.
Using a persistence layer (such as Hibernate) helps insulate over a few other differences. I've had very good success making even major & complex applications, coming from a major migration and re-engineering project, portable from Oracle to MySQL.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have a task to create a store system. The language that I use to program is Java and the information MUST to be saved in the pc where the program runs.
As far as I know Access does that perfectly when it comes to Visual Basic since I can use the Access interface and edit some cdoe with VB.
Another option I thought of is creating some kind of my own import/export system that will save the information into files and loads them when needed which will require a lot of extra coding.
So what should I do? What is the best way to do that with Java?
The standard way to do it would probably be to use an SQL database such as sqlite or mysql, but it depends a lot on what sort of system you're designing. Options are really,
SQL Database (such as sqlite)
NoSQL Database (such as couchdb)
Object serialization. You could just serialize objects and dump them to files.
Do you need to handle concurrency with multiple programs reading and writing to the database? Do you need low risk of data loss or corruption, or could you sacrifice some data safety for a quick and easy implementation? Do you need to store a lot of data or just some? How fast does it need to be accessed, and is it accessed all at once or do you need to query certain things?
We'd really need answers to all of those questions to be able to give you a good answer for what's best.