Frank Lin

Ranch Hand
+ Follow
since Jan 26, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Frank Lin

Folks,
Thanks a lot for the replies. Your guys are the best! After three days' endeavor on Hibernate, I decided to put it to shelf for now. We are pretty much a Weblogic shop, and in a need for a productivity tool in database access/persistence layer. We did not choose Entity Beans because the concensus towards it is its complexity. Maybe I am more familiar with Entity Beans, I felt Hibernate is as complex as Entity Beans, if it is not more complex. It might makes sense if you do not have a full-blown application server, or I don't see why you will pick Hibernate over Entity Beans which at least to have a spec to go by and supported by the whole industry. Besides, Hibernate has a very big foot print and might have conflicts with the application server if you use it in your session bean for persistence. One thing I found out is that the POJO mapping class will not be reloaded when you redeploy your session bean which contains the POJO mapping class, until restarting the server. Also I believe you have more flexibility with Entity Beans because you can at least have your BMP as a choice. There might be good use case for Hibernate, but in real world, you need to have a good mix to leverage both Java/J2EE, and the legacy database objects, such as Stored Proc. I will take a look at the Spring JDBC template and thanks a lot for your information.
Above is just my 2 cents to share. 3 days' work definitely will not make me an expert in the area. Do not be offended by my opinions if you like Hibernate and good luck with your Hibernate projects.
Mark,
Is this HibernateUtil class written by you? I do not see it in the hibernate3.jar. Besides, this is pretty much the same as the regular JDBC call.
Mark,
Thanks for the reply. What I am looking for is some kind of JDBC wrapper feature in Hibernate that allows to run a simple query and get the the result set mapped in a Java collection, without heavy coding of the mapped java object, not mentioning the hibernate xml property file.
Just get started with Hibernate for the second day. I found it very powerful in data persistence, but it is kind of complicated, and requirs a lot of coding, even for small things like running a query and get the result in a Java collection, such as a ArrayList or a Vector. For example, in the following code snippet, instead of mapping the query result to class AuctionInfo, is there anyway to map it to a java collection class? If the intention is only retrieving the data from database for display only, there is no need to create a object to map it. Would Hibernate be an overkill in this case?

Thanks in advance for your reply.


List auctions = s.createQuery(
"select new AuctionInfo( item.id, item.description, item.ends, max(bid.amount) ) "
+ "from AuctionItem item "
+ "left join item.bids bid "
+ "group by item.id, item.description, item.ends "
+ "order by item.ends desc"
)
.setMaxResults(100)
.list();

Iterator iter = auctions.iterator();
while ( iter.hasNext() ) {
AuctionInfo ai = (AuctionInfo) iter.next();
System.out.println(
"Auction: " + ai.getId() + " - " + ai.getDescription() +
", ends: " + ai.getEnds() +
", highest bid: " + ai.getMaxAmount()
);
}

Originally posted by Ilja Preuss:
I can't think of any reason to need a "dynamic type cast". Could you please explain what you want to do?


My question originated from a need to invoke a entity bean dynamicly. As you know, a homeinterface.findByPrimaryKey() returns a remote interface that requires a explicit type cast. What if which bean should be invoked can only be known at run time? Using reflection can be a alternative. Anything else?
22 years ago
In the snippet code below
Object obj = null;
String ss = new String("test");
obj = ss;
String ss2 = (String) obj;
^
Where ^ denote the type casted to. Is there anyway to provide the type at run time dynamically?
22 years ago
Gregg,
Thank you for your help. It works.
22 years ago
Gregg,
Thanks for the reply. The message that I got when starting smbclient is
session request to localhost failed
session request to *SMBSERVER failed
I wish there were more meaningful message that may hint what is wrong.
If you don't mind, could you list steps and parameters to get samba up and running? At least that could help to rule out any possible installation problem on my machine.
Thanks.
22 years ago
Has anyone setup samba on Linux successfully? I had Red Hat 6.2 and went through the config. in /etc/smb.conf. The daemons of smbd and nmdb started OK, but when I tried smbclient -L locolhost, it came back with error: Can not start smb session. Any ideas?
22 years ago
The servlet engine that you use might use a buffer to improve efficiency. The flush() method may only put the data into the buffer.
22 years ago
JSP
I was thinking what would happen if super.method() is called. It proves to be fine since interface does not have a implementation for the method. But it is really confusing to me when it comes to this kind of inheritance hierarchy.
22 years ago
Since Java does not support multiple inheritance, I don't think you can extend a class and implement a interface which have a common method with same signature.
22 years ago
When people compare XSLT to JSP and say JSP will be replaced by XSLT, they are just comparing orange to apple. Sure, XSLT and JSP are all capable of generating HTML for presentation, just like oranges and apples are all fruits, but they have really distinguised features or nutrition serving for different purposes. XSLT and JSP will coexist just like oranges and apples. You will pick one of them mostly depending on what features that you need.
To me,
(1) XSLT is the query and formatting tool for XML, just like SQL to relational data base.
(2) JSP on the other hand, is like a 'glue' to stick things(Static content and dynamic contents in many forms) together
When it comes to presentation layer, they do compete with each other in some circumstance, like presenting the query result in HTML format. You do have the choice to encapsulate the query result as a bean and use JSP to present it, or use XSLT to convert the query result in XML format, which can be generated in native SQL with newer release RDB, to HTML. XSLT will be used more and more in this kind situation.
But things are not always that straight forward. Unlike what is illustrated in the diagram of the article, the model should include both the data model, and business model(Action classes, which should not be in the controller part as in the diagram, EJBs etc). Of course, these all can be mapped(or bound to) XML and then use XSLT to combine them and transform into HTML(Multiple passes are very likely). But in many cases, it will be more effective to use JSP to glue them together and emit the HTML directly.
Even if XSLT would gain all the ground in presenting the result(or generating HTTP Response), JSP is still needed in helping the form beans to capture the data from the form, fascinating the processing of HTTP request etc.
As far as the performance and productivity go, JSP are still ahead of XSLT, at least for now. Debugging a XSL style sheet is much more difficult than debugging a JSP, and JSP page compiler definetly has smaller footprint than XSLT engine and parsers. Anyway, JSP can be (and was designed to be) used by web master. But I really don't think XSLT can be used by a non-programmer effectively unless some kind of tools are developed for that purpose.
I was asked this question and did not have the answer.
Question
If you have a function that handles a particular event, for example, onClick, for all buttons in a form. How do you find out which button triggers the event in your function?
Does anyone know?
Sorry for the confusion. I made a mistake when I cut and paste to make the code snippet. The problem was caused by not setting the column default to NOT NULL. The strange thing was it worked fine with PL/SQL select. With PreparedStatement, the query returns the result when the condition is defined as field_name > 'value' when actualy the query condition should be field_name = 'value'. I think it is something in the JDBC driver.