As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
on my company we are developing a ERP-like app using java and jsf, so far the design team has identified about 20 entities,each with diferent properties, usually we'll be building 20 pages of CRUD , is there any better way to do this?, we are using hibernate as db access, so we came up with the idea of a single DAO for this part of the system, have you faced a similiar situation? what are your thoughts on it?
You really should look into Seam. It has a feature called Seam-Gen that will reverse engineer your entire application CRUD pages from the database. You can edit the Seam-Gen templates (which are based on Freemarker) to customise the pages that will be generated to your liking.
I use the Eclipse plugin Azzurri Clay to model my database and generate the DDL. I then run Seam-Gen and in a few seconds you have a running application. It's a very handy combination.
You might consider codegenerating those 20 screens, much like scaffolding in Ruby does. As far as DAO is concerned, you might pull CUD operations to some generic IBusinessObjectDao, leaving specific R operations (querying by various parameters) to concrete DAO implementations.
I know its late, but I think my little framework would fit this situation perfectly. Check out http://code.google.com/p/happyfacescrud/ . It has search out of box, custom components that recognize datatype of entity, lazy datamodel, and flexibility that code generators can not offer. Here is little sample how page with lazy datatable and search would look like:
<hf:searchPanel columns="4" backingBean="#{accountBean}">
<hf:searchField label="#{messages['account.accountNumber']}" field="accountNumber" />
<hf:searchField label="#{messages['account.active']}" field="active" isMessage="true" />
<hf:searchEntityField label="#{messages['account.customer']}" field="customer" childField="name" popup="true" />
<hf:searchField label="#{messages['account.openingDate']}" field="openingDate" rangeSearch="false" />
</hf:searchPanel>
<hf:dataList label="#{messages['account.search.results']}" backingBean="#{accountBean}">
<hf:column label="#{messages['account.accountNumber']}" field="accountNumber" />
<hf:column label="#{messages['account.active']}" field="active" isMessage="true" />
<hf:column label="#{messages['account.customer']}" field="customer" childField="name" entityView="/pages/customerEdit.xhtml" popupFields="email,phone,address" />
<hf:column label="#{messages['account.openingDate']}" field="openingDate" isDate="true" />
<hf:actionsColumn />
</hf:dataList>
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
I'm looking for a database which would allow me to store most of the objects in the memory. Basically I want to store in the memory everything except some rarely used data (history of changes, etc).
I'm looking for:
simple API for java, preferably non-ORM
ACID is not required (well, D is)
some support for queries, but nothing fancy
The idea is to operate on a model in memory, store any "command" mutating the model in the database, periodically synchronize model to database (like prevayler does)
Which database matches my needs? (I'll use postgres or H2 if there isn't anything simpler).
You need one of object databases: http://en.wikipedia.org/wiki/Comparison_of_object_database_management_systems
You should use Terracotta. It is usually used for caching, but its exactly what you are asking for, except that it's "querying" abilities are sparse.
Update:
The previous link was to their "enterprise" edition, but they have the open source project Ehcache which fits your needs, and their enterprise product is based on.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm about to write a JPA based web application in Java and since it's my first time seriously working with persistent classes and databases in general, I would like to learn if I have to make specific considertions f.i. while designing the overall class structures like building it as flat as possible to keep the count of persistent classes low and the database structure simple. I really don't expect long explanations but would like to get a short overview of general considerations which might not appear to be that obvious to one who is unexperienced with database applications.
Thanks in advance.
general considerations which might not appear to be that obvious to
one who is unexperienced with database applications
Using an ORM is superficially easy and transparent, but there are many small issues to consider:
Object identity. Understand the root mismatch that relational database work with rows and keys, while in the object world, each object has one identity. There various ways to handle identity correctly, or incorrectly.
Mapping Data. First understand how you map simple data types (string, number, URL, etc.). See and understand techniques to handle convertion problems (URL or string, byte or blob).
Mapping Relations. Understand how you map relations (uni- and bi-directional), how to maintain the invariants with proper encapsulation, the issue of "orphans" objects who lost their parent, and how to map several relations to the same class differently, how to load eagerly or lazily and the link with the "N+1" select issue.
Mapping Inheritance. Understand the mismatch between object, class, and tables. Understand how far you can support inheritance with ORM.
Working with Sessions. Understand working with sessions: when an object is attached or detached, what's the impact on lazy loading, how to deal with optimistic locking, the link between transaction and session.
There is an abundant literature on JPA and ORM in general. The list above is just what came to my mind.
Ideally, ORM should not impose constraints on your design. However, my advice would be keep it flat and simple.
You should go through this first
http://www.oracle.com/technetwork/articles/marx-jpa-087268.html
There is no need to make your database simpler because you're using JPA.
One of the main benefits of JPA is that it manages relationships for you.
It would be a pretty crappy API if you had to dumb down your database just to use it!
(espcially since it's typically used in a JavaEE environment)
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
There are a lot books/online resources about using patterns. But I didn't find any tasks for using it. But for good understanding of patterns it's need practice. Maybe someone faced with some resources where there are tasks for using patterns.
For example. Mediator pattern:1)write chat application where...
Thanks in advance.
UPDATE:
I found:
http://www.cs.sjsu.edu/~pearce/modules/labs/patterns/
How to study design patterns?
I'll give you five, with easy and/or moderate difficulty:
Singleton
easy: single database access class for the entire application.
Factory
easy: English-to-another-language translator. I need to be able to add and then access a new language translator with minimal code changes.
Observer
easy: Central data structure that has several copies within the application that need to be updated automatically when a change to the main DS occurs.
moderate: Make this work over a network with cooperating processes updating a central data structure.
Memento
easy: A simple game with the ability to save/load.
Decorator
easy: A simple persistence class with read/write ability. I want to be able to dynamically switch between XML or database persistence.
I know only of one such resource, and it is not formulated as you have specified, but maybe it'll help a bit: In the last chapters of the Head First Design Patterns book, the MVC pattern is explained as a compound pattern, involving several others : Composite, Strategy, Adapter etc.
It is explained with the help of a small application. You could look up the chapter and build the described to practice.
Ever use an iterator? Pattern. My guess is you use a lot of patterns without even really realizing you're using them. Created a buffered reader out of a file reader? Decorator; pattern. Don't set out trying to use patterns--let the problem discover them. They're everywhere, that's why they're patterns.
Things like facades, decorators, iterators, factories, etc. crop up in every single domain. Pick anything you're interested in writing, and discover the patterns already present. Refactor mercilessly--patterns.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I'm doing some text mining in web pages. Currently I'm working with Java, but maybe there is more appropriate languages to do what I want.
Example of some things I want to do:
Determine the char type of a word based on it parts (letter, digit, symbols, etc.) as Alphabetic, Number, Alphanumeric, Symbol, etc.(there is more types).
Discover stop words based on statistics.
Discover some gramatical class (verb, noun, preposition, conjuntion) based on statistics and some logics.
I was thinking about using Prolog and R (I don't know much about these languages), but I don't know if they are good for this or maybe, another language more appropriate.
Which can I use? Good libs for Java are welcome too.
python.!
They have a HELL-LOTTA libraries in this area.
but, i've got no knowledge about prologue and R.. but definitely py is LOT better than java in text mining, and AI stuff...
I highly recommend Perl. It has a lot of text-processing features, web search and parsing, and a large etc. Take a look at the available modules (>23.000 and growing) at CPAN.
I think Apache Solr and Nutch provides you the framework for that and on top of that you can extend it for your requirements.
Java has some basic support, but nothing like the above two products, they are awesome!
HTML Unit might give you some good APIs for fetching web pages, and traversing over elements in DOM by XPath. I have used it for sometime to perform simple to more complex operations.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 9 years ago.
Can any one list out the tips to tune JSF WebApp # its best.
JSF RichFace
Never put logic into your getters.
They are called multiple times and
should only return something already
populated by another method. For
example if you are chaining drop-downs
together use an a4j:support tag on the
first one with an action attribute
that loads the data which is then
retrieved when you reRender the second
one.
Use the ajaxSingle="true" unless
you actually want to send the whole
form back to the server.
Don't use a
rich component if you only need a
normal one. For example don't use
rich:dataTable unless you are making
use of some of the features that it
has over and above h:dataTable.
Consider using immediate=true
attributes on elements where you do
not need validation Avoid displaying
large tables to user.
Use pagination
Do not over complicate EL expressions,
code them in Java in backing bean
JSF BestPractices
Performance Tuning
Moving to Stateless JSF would offer a great performance boost. Now it's possible to use JSF entirely stateless. See this blog & this issue. A payoff is that you can't create views dynamically (e.g. by binding, JSTL tags, etc), nor manipulate it after creation.
A Stateless JSF operation mode
would be incredibly useful for high-load applications and
architectures:
http://industrieit.com/blog/2011/11/stateless-jsf-high-performance-zero-per-request-memory-overhead/#comment-4
This has previously been suggested by Jacob:
http://weblogs.java.net/blog/jhook/archive/2006/01/experiment_goin.html
This would help JSF ditch the stigma of "slow and memory hog," and
help keep up with current tech trends (stateless architectures.)