News: Presto - The Prevayler Pet Store
The Prevayler team have their own implementation of the infamous PetStore. It was written to be as simple as possible, and acts as a good tutorial for Prevayler itself.
- Posted by: Dion Almaer
- Posted on: August 16 2004 10:39 EDT
Presto - The Prevayler Pet Store
Download the source code
- All other things being equal ... by Guglielmo Lichtner on August 16 2004 12:54 EDT
- All other things being equal ... by Alan Borsato on August 16 2004 15:52 EDT
- How do you do search on data ? by Vagif Verdi on August 16 2004 10:07 EDT
- All other things being equal ... by Guglielmo Lichtner on August 17 2004 09:55 EDT
- No database....haaa haaaaaaaa haaa haaaaaa by Jonathan Gibbons on August 17 2004 03:15 EDT
- All other things being equal ... by Alan Borsato on August 16 2004 15:52 EDT
- Presto - The Prevayler Pet Store by Joshua Y on August 16 2004 13:12 EDT
- Presto - The Prevayler Pet Store by irenicus irenicus on August 17 2004 03:38 EDT
- Object versions? by Luke S on August 17 2004 04:14 EDT
- This rocks on the client side applications by bad mASH on August 17 2004 10:19 EDT
- A challenge! by geoff hendrey on August 17 2004 12:38 EDT
Although Prevayler is a brilliant thing, the J2EE and .NET versions have an advantage: running the system generates a relational database of data. I think what's missing here is a mapping tool that replicates prevayler state to a relational database.
The issue of object prevalence doesn't even touch this problem: it's an issue of network-model vs. relational databases.
Prevayler doesn't need database.
Please, read http://www.prevayler.org/wiki.jsp?topic=PrevaylerIsNotADatabase
Could you provide small example of how would you do query in Prevailer ?
Search is the only thing that puts me off of Object Oriented databases.
Thanks for the link. I've read that page. And it actually says - we do not do queries and do not have any comparable mechanizm. Further it suggests using for searches... while loops. I'm fine with writing search functionality manually.
But what about speed ? If I want to find list of open orders for particular customer, sure search code is simple. But in a database of hundred thousands of orders, how it performs against relational database, that is using indexes for this kind of search ? Is is fast ? how fast ? Can you give any measurements ?
You could always use something like OGNL
Prevayler doesn't need database.I know that. What I am saying is that companies do. You can build a great application on prevayler, but eventually the rest of your organization might want to run arbitrary queries on the data generated.
This is especially true for pet store, i.e. retail. People need to be able to run GROUP BY queries with aggregates to find out which products are doing well and which are not.
So I am saying either build this capability (sql support) into Prevayler or write some glue so you can replicate the data out to a relational database.
I am not really proposing this. I am just telling the way things are.
Even MS is giving away embedded SqlServer.
MySql is free and scales.
Oracle is distributed, multimedia, disaster recoverable, cross platform, multi language, data warehousing, clustered, bladed and great.
Sybase is much the same.
SQL is brilliant at relational mining.
And these guys are saying store it in a flat file. Surely, by now, the software industry has wisdom. Be wise, don't be silly.
Your companies life blood is the data. Your projects tools are the objects that sit on top of the data. Data lives long beyond your projects object model, even beyond your projects choice of language and platform.
Emeraldjb - Bringing Databases, Java and Developers together.
lol, just like Bill Gates saying: "we will never need more tham 640KB".
Don't flame ideas, help them evolve.
OK. Sorry if I was harsh.
what good it has by winning LoC game over reference implementation??? Developers already know LoC does not matter when talking about the quality of the application. Want to see more explanation about what strategy this demo employed except reducing lines of code.
... Developers already know LoC does not matter when talking about the quality of the application ...We are talking about the same underlying language here (Java) and the same set of requirements (Petstore). In this case less LoC does leed to improved quality! It will always be easier to find and fix issues when there are less lines of code around and so it will be easier to achieve higher quality with less lines of code.
Prevayler essentially lifts (depending on your point of view I guess) the developer to work solely with the semantics of Java and Java objects (a higher semantic level IMO than a relational model). ORM based solutions are essentiall relational model wrappers, that require great sophistication to come close to resembling pure Java object semantics (i.e. you have to know in great detail what you can and can't do and be expert in both Java and relational databases).
ORM based solutions are essentiall relational model wrappers, that require great sophistication to come close to resembling pure Java object semantics (i.e. you have to know in great detail what you can and can't do and be expert in both Java and relational databases).Have you checked out JDO? JDOQL is Java Data Objects (JDO) query language. The semantics look exactly like Java.
"lastName=="Smith" && orders.contains(o) && o.price > 100.0"
That's basically pure Java object semantics. The BNF for JDOQL is essentially a subset of Java.
JDOQL is actually very limited to be almost useless as a query language.
You're better off with something that supports
Projection and Selection.
I ever implemented Prevayler in a middle scaled project. When the snapshot file sized around 30 MB, Tomcat consumed around 300MB to run Prevayler. And I have no idea of how to refactor the POJO efficiently. Because everytime something changes in the POJO, property, package, or anyelse, the object won't load anymore. We have to do some kind of versioning, or complex migration. IMHO prevayler will "rock" if: 1. we can browse the prevayler snapshot file with some kind of database console 2. we can export the snapshot file to xml or another type of database (some kind of "dump") 3. we can use SQL query string as an alternative to access the prevayler data
I just had a look at the test results. While i believe them i'd say they are not telling the whole truth. It is nice that you can query your data by using HashMaps .No non java database can get event close to this as it at least has to transfer the date from to the VM where all the nice java objects have to be instantiated. (This might look different if you are are using a pure java RDBMS). But your program does usually do more than just query the database. And one thing i have learned is that keeping more data in memory than necessary slows down your application as the garbage collection has to much more work to do. So it doesn't make sense to keep 1.000.000 objects in memory whne you usually need only a few percent of them. Sometimes less caching can improve the performance, but of course this depends on your application. And if you we are talking about applications that have their own object caches things look different too.
One of the things that has always put me off using prevayler is what happens when you want to change your data objects, e.g. add a new field / property to a bean. Since prevayler is based on serialization, when I change my objects how am I going to upgrade my existing serialized objects? Alright you might be able to get around that using serialUIDs or custom externalization methods to some extent. But what about if I want to refactor my code , take a class and make it abstract with 2 concrete child classes for example. How am I going to convert my existing prevalent serialised objects. The only ways I can think of (never having used prevayler) is to load old and new code bases in different class loaders and somehow convert the prevalent system in one to a fresh prevalent system in the other (gonna need a lot of memory potentially!), or to serialise the code base as XML and then transform it with XSLT to have the required structure and then load it back in to prevayler.
I guess with RDBMS this is as easy as adding a column to a table.
Genuinely curious about answers to the above questions, would probably use prevayler for small projects if I thought it wasn't going to unnecessarily tie my hands with regards to data and code transformations.
This is a better solution that embedding Cloudscape or HSQLDB etc. in client side applications.
Just my $0.02
let me preface this by saying I am not a Prevayler user, so if anything I say is innacurate, please correct me.
The claim is being made that "Prevayler is not a database". Then the claim is made that, although prevayler is not a database, it is thousands of times faster than several well known relational databases.
This is like saying:
"A horse is not a car. But, my horse can eat hay 3000 times faster than your car."
Let's take a step back and ask oursevles why applications are built on top of relational databases:
1) Transactional consistency amongst multiple concurrent users
On this point there is no reason why prevalylor, running as a server, can't compete with a traditional database,and even be faster. +1 for Prevayler. However, all the applications will have to be written in Java. -1 for Prevayler.
2) Standards based access to data from any programming language/environment
Prevayler iterates objects in Java to perform queries. No Java, no prevayler.
-1 for Prevayler. A relational database has a standard (SQL) interface accessible via TCP/IP. If the claim is being made that Prevayler is faster than a database with a networked TCP/IP SQL interface, even over localhost, the network stack will degrade performance. The prevayler interface does not allow access via SQL, so why are they benchmarking against JDBC/SQL access to MySQL and Oracle? A fair test of comparable functionality on MySQL would be written in C and use the MySQL native interfaces, for example, to do the query.
3) Ability to query a large dataset
It has been pointed out (I can't vouch for this), that the queries used for comparison between relational databases and prevayler were so simplistic that they only used a single table. Relational databases are all about doing joins on large datasets. A relational database is designed so that the dataset DOES NOT have to be entirely in memory. That is what disk bases indices are for. Can prevayler execute the following object filter on 25 million records faster than MySQL? (pseudo query language)
CustomerA.balance < 500.0 && ((CustomerA.account.creationDate < "3/12/2000") && (CustomerA.account.creationDate > "12/1/1995")) || CustomerA.accountStatus == "expired" ORDER By CustomerA.lastName
Data in a relational database can be accessed from multiple applications. In almost any production environment you have Perl scripts that do report generation, etc. As far as I know there is no way for the Prevayler data to be exposed to any applications other than the Java app that created the data.
-1 for prevayler.
There are many other reasons or using a database. I've just hit on a few. If you don't need standards bases access, and if you don't need the ability to query a large dataset, and if your dataset fits into RAM, and if you don't need other apps to report on your dataset, than Prevayler is an excellent fit.
Here's the thing. The Java community *needs* technologies like Prevayler that are simple, direct, and FAST. These are exactly the types of technologies that if applied to the right problems will show how competitive Java is with .NET. So I applaud the Prevayler Pet Store.
But there is no free lunch. Running around saying Prevayler is 3000 times faster than a relational database begs for a more detailed analysis of exactly what Prevayler can do 3000 times faster.