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 3 months ago.
Improve this question
I have always used a double bond in entities.
For example, we have 2 entities "basket" and "product"
In both entities, I put the annotations #ManyToMany (or #ManyToOne and #OneToMany, depending on the logic)
On the new project, I see that the annotations #OneToMany, #ManyToMany can only stand for one entity.
Can anyone explain this is the right approach or the opposite is extremely wrong.
In all the books nothing is said about this, everywhere communication is maintained from 2 sides.
Is it possible that this is done for optimization so that the "product" does not receive information about the "basket" ?
Let me restate my question.
Are there any advantages (optimization or architectural approach) or disadvantages. Is it worth avoiding two-way relationship in the future, so that Hibernate doesn't load unnecessarily?
Related
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 have some pre initialized objects of some class. These objects are heavy weight objects and each correspond to some configuration options specified by user. There will be exactly one instance corresponding to one configuration and same will be used every time.
My question is, which design pattern suits best to handle this kind of situation?
Most likely a Flyweight is what you are looking for. https://en.wikipedia.org/wiki/Flyweight_pattern
This can be used for pre-initialise heavy weight objects and reuse them.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Hey guys, I'm having a doubt about the implementation of class diagram above, confused between the Single_table strategy and the joined_table strategy, any help, any suggestion about the patterns followed in this case that are used to enhance the response time of the login process.
Any help will be appreciated.
Thank you guys in advance :).
If I got you right your concern is whether to us a table User with a flag of different Professor etc. tables. Well, I'd go for the single table. Actually there is not much difference in performance. In order to retrieve the professors from the user table you would need a WHERE clause while a native table has the records ready. The time difference in any case would be near to null as a RDBMS will handle WHERE clauses very effectively granted the DBA has set good indices. A single table is easier to maintain with respect to maintaining all the columns you need (but which your class diagram currently does not show).
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 9 years ago.
Improve this question
I am using #NamedQueries but not sure what is the best way to use it.
Use it above entity class
Use it above DAO class
Create One NamedQueriesFactory class which will have centralized named queries for all Entity
Any other better way.
i good way would be to put all of them in an xml file which is used a lot. this externalizes your queries and gives you the freedom of just sending over this xml file to some DBA for easier analysis later on.
2 (Dao) and 3 (factory class) are not real options, assuming that those are not also entities, because according documentation:
The NamedQueries annotation can be applied to an entity or mapped
superclass.
That leaves as with 1 (entity) and 4 (mapped superclass). I would locate queries by return type and/or main entity accessed in query. Because mapped superclass cannot be returned from the JPQL queries, answer would be 1 (entity).
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 4 years ago.
Improve this question
Take twissandra as an example, when a new tweet is received, not only the column family for the tweet need to be updated, but a few other (super) column families need to be updated. Definitely we can do this in sequential, on receiving the new tweet, to update each family one by one. But what if there are a dozen column families out there need to be updated? This doesn't seem to be an efficient approach to me. Is any other way, either relying on the programming framework (Java eg), or relying on other "utilities" like Message Queue, or a better programming model/design pattern to make this more scalable and maintainable?
Yes, you can use batch mutations to group together a set of updates. For example, in Hector, you can do something like:
mutator.addInsertion("jsmith", "Standard1",
HFactory.createStringColumn("first", "John"))
.addInsertion("jsmith", "Standard1", HFactory.createStringColumn("last", "Smith"))
.addInsertion("jsmith", "Standard1", HFactory.createStringColumn("middle", "Q"));
mutator.execute();
See https://github.com/rantav/hector/wiki/User-Guide under "Inserting Multiple Columns with Mutator".
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
What are some good data structures for keeping track of agents in a two-dimensional, spatial simulation?
I've seen some references to quadtrees (which I understand) and kd-trees (which I don't understand very well).
I'm looking for something through which an agent can efficiently say, "I know my location, and I would like to know which agents are near me (within a certain radius of myself)."
Examples (pseudo-code is fine) would be greatly appreciated.
I'm working in Java.
Well, I'm not sure exactly how it is implemented, but the MASON toolkit uses a discretization algorithm that places agents that are close to one another in the same "bucket" of a hash table. It makes for very fast lookups, as only a few of these buckets have to be checked for each query.
The best thing for you is probably to take a look at the source code here:
http://code.google.com/p/mason/source/browse/trunk/mason/sim/field/continuous/Continuous2D.java?r=529
I have found something called a Bucket PR Quadtree.