I am trying to deploy a CMP entitybean which maps to columns in 2 different tables.
The jaws.xml section for the same looks like below:
I get the following error when i run the test client to create the bean.
[WARN,PreparedStatementFactory] Error creating prepared statement.
SQL Exception: Syntax error: Encountered "," at line 1, column 28.
at RmiJdbc.RJConnectionServer_Stub.prepareStatement(Unknown Source)
at org.jboss.pool.jdbc.PreparedStatementFactory.createObject(Unknown Source)
at org.jboss.pool.cache.LeastRecentlyUsedCache.addObject(Unknown Source)
at org.jboss.pool.cache.LeastRecentlyUsedCache.getObject(Unknown Source)
at org.jboss.pool.cache.LeastRecentlyUsedCache.useObject(Unknown Source)
at org.jboss.pool.jdbc.xa.wrapper.XAClientConnection.prepareStatement(Unknown Source)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Native Method)
at java.security.AccessController.doPrivileged(Native Method)
It throws error saying not able to prepare sql statement as given above.
It seems JAWS is unable to take more than one table names in the <table-name> tag.
Could anyone please help me out how to map one entity bean to multiple tables using JBOSS 2.4.4 with tomcat?
Thanks in advance.
I don't know of any EJB servers that support this. Switch to CMP 2.0 and create two entites with a one-to-one cascade-delete relationship.
As far as I know, Websphere and Borland app server supports this.
I think this type of mapping is kind of lame, but if there is sufficent demand I'll add it. In the mean time you will have to do the joined entity trick or get out your check book.
I'm thinking of converting all CMPs to BMPs. What you think about it? I can stay away from the mapping issues and hence porting from one app server to another app server becomes easier.
> I'm thinking of converting all CMPs to BMPs. What you
> think about it? I can stay away from the mapping
> issues and hence porting from one app server to
> another app server becomes easier.
Try converting one or two. When you get the first 5k lines of code down, you'll come back.
As I said, if there is sufficent demand I'll add the mapping, but from what I see, you are the only one interested in this mapping. If you really want it, you can always pay for priority development.
Im just wondering why this functionality is not provided. I only have a small amount of Bean experience but if you want a view into two tables would it not be better/more efficient to only have to instantiate one Bean rather than two. So if you wanted to requrn a large amount of information would having a CMP mapped to two tables not half the amount of Beans instantiated at any one time.
Im sure im misunderstanding the use of CMPs in some way so maybe you could clarify this for me....
What kind of money you are talking about to add this feature?
I don't know; I haven't seriously how long it would take, but I have some design ideas. If you are seriously interested, contact firstname.lastname@example.org.
As for BegleBoy, if you database supports updateable views, just create a view and map the entity to the view.
I have sent an email to sales to find out the details.
I like the idea of using updatable views. We're using Cloudscape, DB2 and MS SQL Server 2000.
I dont know whether all of them support updatable views?
SQL Server does, but I have never used the other two. I would bet DB2 does.
Since it was asked if anyone else is interested in this functionality (CMP mapping of one entity to many tables), I should state for the record that I am!
In general, I feel that this capability is fairly important when porting legacy RDB-based systems to newer EJB technology. The reason being that legacy DB schemas are often really clunky from an entity modelling point of view (having organically evolved over long periods of time to fit changing requirements), and there is also a common constraint to not radically change the DB schema for legacy code maintenance / customer support / data-migration issues. Thus, the idea of taking a legacy schema and simply modifying it to fit a sounder EJB-targeted entity model is simply not an option in this real-world scenario.
Therefore, it can be a real help to be able to "clean up" the logical entities in the EJB layer and let CMP resolve the complex mapping to the physical legacy schema.
I think that the reason that this request has not been too common thus far is that many EJB projects are for new apps (or web-site-based apps having DBs that never get installed into customer sites) that have the liberty of being able to change the schema at will (though it is never a costless operation ;-), in which case it is straightforward enough to make it fit a nice EJB entity model in a one-to-one fashion. However, as EJB gains more acceptance in the marketplace, I think we will find that more companies will add EJB logic on top of old legacy schemas for various reasons. Then one-to-many entity-to-table mapping will become a more popular item.
In my particular case, it is pretty important right now; I also feel it is a crucial feature for JBoss architects to anticipate as more requests come in for it.
I agree with "cstone" because unfortunately a lot of projects won't setup on a green field. So I think that the mapping to multiple tables in the real project world will be frequently an important criteria for choosing an application server. I don't know when we can discuss about JBoss 4.0 and because I believe in the potential of JBoss I can imagine that this feature could be a big point in competition with the "big players". And what I want to say is that the multiple table mapping feature is surely not the special requirement of "cstone" but it is the constraint of the real project world.
Just for the record, he is far from the only one interested in this mapping.