| <?xml version="1.0"?> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| <!-- |
| * Simple demo that insert a row into hsqldb using OJB with ODMG |
| * |
| * @author <a href="mailto:antonio@apache.org>Antonio Gallardo</a> |
| * @version CVS $Revision: 1.3 $ $Date: 2004/03/17 11:28:20 $ |
| --> |
| |
| <xsp:page language="java" xmlns:xsp="http://apache.org/xsp"> |
| |
| <xsp:structure> |
| <xsp:include>org.apache.cocoon.ojb.odmg.components.ODMG</xsp:include> |
| <xsp:include>org.apache.cocoon.ojb.samples.bean.Department</xsp:include> |
| <xsp:include>org.odmg.Implementation</xsp:include> |
| <xsp:include>org.odmg.Transaction</xsp:include> |
| <xsp:include>org.odmg.ODMGException</xsp:include> |
| </xsp:structure> |
| |
| <page> |
| <content> |
| <title>Hello</title> |
| <para>This is my first Cocoon page with OJB!</para> |
| <xsp:logic> |
| ODMG odmg = null; |
| try { |
| /* Get the implementation */ |
| Implementation impl = null; |
| try { |
| odmg = (ODMG) manager.lookup(ODMG.ROLE); |
| impl = odmg.getInstance("personnel"); |
| } catch (ComponentException cme) { |
| getLogger().error("Could not look up the ODMG Implementation", cme); |
| } catch (ODMGException oe) { |
| getLogger().error("Failed to instantiate ODMG Implementation", oe); |
| } |
| |
| <!-- Setting up the Bean --> |
| Department bean = new Department(); |
| bean.setId(6); |
| bean.setName("ODMG Development"); |
| <!-- 2. Get current transaction --> |
| Transaction tx = impl.newTransaction(); |
| <!-- 3. Start a Transaction --> |
| tx.begin(); |
| <!-- 4. now perform persistence operations. Store the new Department --> |
| tx.lock(bean, Transaction.WRITE);; |
| <!-- 5. Commit the transaction --> |
| tx.commit(); |
| |
| <p> |
| Inserted data: <xsp:expr>bean.getId() + " : " + bean.getName()</xsp:expr> |
| </p> |
| |
| } finally { |
| manager.release(odmg); |
| } |
| </xsp:logic> |
| </content> |
| </page> |
| </xsp:page> |