Re: OSUser Hibernate Provider Updates
Mike Cannon-Brookes <[email protected]> Tue, 20 Apr 2004 13:28:31 +1000
| Newsgroups | gmane.comp.java.open-symphony.devel |
|---|---|
| Message-ID | <[email protected]> |
Erik,
Are these added to an issue in JIRA? If not - it's a great place to
store patches before they're applied :)
Cheers,
Mike
--
ATLASSIAN - http://www.atlassian.com/
Confluence - the professional J2EE wiki - tried it yet?
http://www.atlassian.com/confluence/
On 29/03/2004, at 10:29 AM, Erik Beeson wrote:
> The hibernate providers in CVS don't work out of the box. I've made a
> few updates (with patches) to them and now the example works with
> hibernate providers and hsqldb backend.
>
> 1. HibernateGroupImpl.hbm.xml and HibernateUserImpl.hbm.xml should be
> moved from package ...provider.hibernate.entity to package
> ...provider.hibernate.impl and need to be edited to reflect this
> package move. (The classes have already been moved, but the hibernate
> configuration files haven't.)
> The other option here is to have the hbm.xml files associated with the
> interfaces (HibernateUser/HibernateGroup), but since the whole point
> of all this abstraction is to provide your own implementation, I
> figured the hbm.xml files were implementation specific.
> Another issue is doing this breaks
> ...providers.hibernate.doa.HibernateQueries. Should the queries be
> implementation specific (and therefore moved to impl) aswell?
> 2. The property create.tables doesn't actually create tables in the
> database, just prints them. Add show.tables to do what create.tables
> currently does and fix create.tables. Both default to false.
> 3. Add example-war task to create a .war example in addition to a
> .ear.
> 4. Update hibernate.
> It looks like PropertySet was built against a newer (or at least
> different) version of hibernate, and throws the following exception
> when trying to load viewuser.jsp:
>
> java.lang.NoSuchMethodError:
> net.sf.hibernate.Query.setString(Ljava/lang/String;Ljava/lang/
> String;)Lnet/sf/hibernate/Query;
> at
> com.opensymphony.module.propertyset.hibernate.HibernatePropertySetDAOUt
> ils.getKeysImpl(HibernatePropertySetDAOUtils.java:48)
> at
> com.opensymphony.module.propertyset.hibernate.HibernatePropertySetDAOIm
> pl.getKeys(HibernatePropertySetDAOImpl.java:70)
> at
> com.opensymphony.module.propertyset.hibernate.HibernatePropertySet.getK
> eys(HibernatePropertySet.java:53)
> at
> com.opensymphony.module.propertyset.AbstractPropertySet.getKeys(Abstrac
> tPropertySet.java:284)
> at _viewuser__jsp._jspService(/osuser_example/viewuser.jsp:119)
> at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
> at com.caucho.jsp.Page.subservice(Page.java:506)
>
> Also, the patch for #2 mentioned above needs the latest version.
>
>
> Notes about patches:
>
> 1. The patch will edit the 3 files that need editing, but the
> hbm.xml files will still need to be moved. Patch fixes
> HibernateQueries aswell.
> 2. With create.tables set to true, the tables will be exported to
> the database everytime the provider is initialized. SchemaExport
> always drops the old tables before trying to create. SchemaUpdate
> doesn't drop the tables. Latest patch fixes this.
> 3. This just dumps all of the jars into WEB-INF/lib and makes a war
> out of the example webapp.
>
>
> --Erik
> Index:
> src/java/com/opensymphony/user/provider/hibernate/entity/
> HibernateGroupImpl.hbm.xml
> ===================================================================
> RCS file:
> /cvs/osuser/src/java/com/opensymphony/user/provider/hibernate/entity/
> HibernateGroupImpl.hbm.xml,v
> retrieving revision 1.1
> diff -u -r1.1 HibernateGroupImpl.hbm.xml
> ---
> src/java/com/opensymphony/user/provider/hibernate/entity/
> HibernateGroupImpl.hbm.xml 12 Jan 2004 20:56:59 -0000 1.1
> +++
> src/java/com/opensymphony/user/provider/hibernate/entity/
> HibernateGroupImpl.hbm.xml 28 Mar 2004 22:17:54 -0000
> @@ -4,7 +4,7 @@
> "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
>
> <hibernate-mapping>
> - <class
> name="com.opensymphony.user.provider.hibernate.entity.HibernateGroupImp
> l"
> + <class
> name="com.opensymphony.user.provider.hibernate.impl.HibernateGroupImpl"
> table="os_group" dynamic-update="true" >
> <!-- <jcs-cache usage="read-write"/>-->
> <id name="id" type="long" column="id" unsaved-value="0">
> @@ -15,7 +15,7 @@
> <set name="users" table="os_user_group" inverse="true"
> cascade="none" lazy="false">
> <!-- <jcs-cache usage="read-write"/>-->
> <key column="group_id"/>
> - <many-to-many column="user_id"
> class="com.opensymphony.user.provider.hibernate.entity.HibernateUserImp
> l"/>
> + <many-to-many column="user_id"
> class="com.opensymphony.user.provider.hibernate.impl.HibernateUserImpl"
> />
> </set>
>
> </class>
> Index:
> src/java/com/opensymphony/user/provider/hibernate/entity/
> HibernateUserImpl.hbm.xml
> ===================================================================
> RCS file:
> /cvs/osuser/src/java/com/opensymphony/user/provider/hibernate/entity/
> HibernateUserImpl.hbm.xml,v
> retrieving revision 1.1
> diff -u -r1.1 HibernateUserImpl.hbm.xml
> ---
> src/java/com/opensymphony/user/provider/hibernate/entity/
> HibernateUserImpl.hbm.xml 12 Jan 2004 20:56:59 -0000 1.1
> +++
> src/java/com/opensymphony/user/provider/hibernate/entity/
> HibernateUserImpl.hbm.xml 28 Mar 2004 22:18:14 -0000
> @@ -4,7 +4,7 @@
> "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
>
> <hibernate-mapping>
> - <class
> name="com.opensymphony.user.provider.hibernate.entity.HibernateUserImpl
> " table="os_user" dynamic-update="true">
> + <class
> name="com.opensymphony.user.provider.hibernate.impl.HibernateUserImpl"
> table="os_user" dynamic-update="true">
> <!-- <jcs-cache usage="read-write"/>-->
> <id name="id" type="long" column="id" unsaved-value="0" >
> <generator class="vm"/>
> @@ -16,7 +16,7 @@
> <set name="groups" table="os_user_group" inverse="false"
> cascade="none" lazy="false">
> <!-- <jcs-cache usage="read-write"/>-->
> <key column="user_id"/>
> - <many-to-many column="group_id"
> class="com.opensymphony.user.provider.hibernate.entity.HibernateGroupIm
> pl"/>
> + <many-to-many column="group_id"
> class="com.opensymphony.user.provider.hibernate.impl.HibernateGroupImpl
> "/>
> </set>
>
> </class>
> Index:
> src/java/com/opensymphony/user/provider/hibernate/dao/
> HibernateQueries.java
> ===================================================================
> RCS file:
> /cvs/osuser/src/java/com/opensymphony/user/provider/hibernate/dao/
> HibernateQueries.java,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 HibernateQueries.java
> ---
> src/java/com/opensymphony/user/provider/hibernate/dao/
> HibernateQueries.java 4 Aug 2003 17:48:43 -0000 1.1.1.1
> +++
> src/java/com/opensymphony/user/provider/hibernate/dao/
> HibernateQueries.java 28 Mar 2004 23:13:48 -0000
> @@ -4,8 +4,8 @@
> */
> package com.opensymphony.user.provider.hibernate.dao;
>
> -import com.opensymphony.user.provider.hibernate.entity.HibernateGroup;
> -import com.opensymphony.user.provider.hibernate.entity.HibernateUser;
> +import
> com.opensymphony.user.provider.hibernate.impl.HibernateGroupImpl;
> +import
> com.opensymphony.user.provider.hibernate.impl.HibernateUserImpl;
>
>
> /**
> @@ -14,9 +14,9 @@
> public class HibernateQueries {
> //~ Static fields/initializers
> /////////////////////////////////////////////
>
> - public static final String USER_BY_USERNAME = "select distinct
> hibuser from hibuser in class " + HibernateUser.class + " where
> hibuser.name = ? ";
> - public static final String USER_BY_USERNAME_AND_GROUPNAME =
> "select distinct hibuser from hibuser in class " + HibernateUser.class
> + ", hibgroup in hibuser.groups.elements where hibuser.name = ? and
> hibgroup.name = ?";
> - public static final String ALL_USERS = "from hibusers in class "
> + HibernateUser.class;
> - public static final String GROUP_BY_GROUPNAME = "select distinct
> hibgroup from hibgroup in class " + HibernateGroup.class + " where
> hibgroup.name = ? ";
> - public static final String ALL_GROUPS = "from hibgroups in " +
> HibernateGroup.class;
> + public static final String USER_BY_USERNAME = "select distinct
> hibuser from hibuser in class " + HibernateUserImpl.class + " where
> hibuser.name = ? ";
> + public static final String USER_BY_USERNAME_AND_GROUPNAME =
> "select distinct hibuser from hibuser in class " +
> HibernateUserImpl.class + ", hibgroup in hibuser.groups.elements where
> hibuser.name = ? and hibgroup.name = ?";
> + public static final String ALL_USERS = "from hibusers in class "
> + HibernateUserImpl.class;
> + public static final String GROUP_BY_GROUPNAME = "select distinct
> hibgroup from hibgroup in class " + HibernateGroupImpl.class + " where
> hibgroup.name = ? ";
> + public static final String ALL_GROUPS = "from hibgroups in " +
> HibernateGroupImpl.class;
> }
> Index:
> src/java/com/opensymphony/user/provider/hibernate/impl/
> OSUserHibernateConfigurationProviderImpl.java
> ===================================================================
> RCS file:
> /cvs/osuser/src/java/com/opensymphony/user/provider/hibernate/impl/
> OSUserHibernateConfigurationProviderImpl.java,v
> retrieving revision 1.4
> diff -u -r1.4 OSUserHibernateConfigurationProviderImpl.java
> ---
> src/java/com/opensymphony/user/provider/hibernate/impl/
> OSUserHibernateConfigurationProviderImpl.java 22 Dec 2003 00:36:05
> -0000 1.4
> +++
> src/java/com/opensymphony/user/provider/hibernate/impl/
> OSUserHibernateConfigurationProviderImpl.java 28 Mar 2004 22:17:32
> -0000
> @@ -11,8 +11,6 @@
> import com.opensymphony.user.provider.hibernate.dao.HibernateGroupDAO;
> import com.opensymphony.user.provider.hibernate.dao.HibernateUserDAO;
> import com.opensymphony.user.provider.hibernate.dao.SessionManager;
> -import com.opensymphony.user.provider.hibernate.entity.HibernateGroup;
> -import com.opensymphony.user.provider.hibernate.entity.HibernateUser;
>
> import net.sf.hibernate.HibernateException;
> import net.sf.hibernate.MappingException;
> @@ -82,8 +80,8 @@
> configuration = new Configuration();
>
> try {
> - configuration.addClass(HibernateGroup.class);
> - configuration.addClass(HibernateUser.class);
> + configuration.addClass(HibernateGroupImpl.class);
> + configuration.addClass(HibernateUserImpl.class);
> configuration.addClass(PropertySetItem.class);
>
> if (configurationProperties != null) {
> Index:
> src/java/com/opensymphony/user/provider/hibernate/
> HibernateBaseProvider.java
> ===================================================================
> RCS file:
> /cvs/osuser/src/java/com/opensymphony/user/provider/hibernate/
> HibernateBaseProvider.java,v
> retrieving revision 1.1.1.1
> diff -u -r1.1.1.1 HibernateBaseProvider.java
> ---
> src/java/com/opensymphony/user/provider/hibernate/
> HibernateBaseProvider.java 4 Aug 2003 17:48:43 -0000 1.1.1.1
> +++
> src/java/com/opensymphony/user/provider/hibernate/
> HibernateBaseProvider.java 28 Mar 2004 23:47:14 -0000
> @@ -14,7 +14,7 @@
>
> import net.sf.hibernate.HibernateException;
> import net.sf.hibernate.MappingException;
> -import net.sf.hibernate.tool.hbm2ddl.SchemaExport;
> +import net.sf.hibernate.tool.hbm2ddl.SchemaUpdate;
>
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> @@ -82,9 +82,12 @@
>
> configProvider.setupConfiguration(properties);
>
> - if ("true".equals(properties.getProperty("create.tables",
> "false"))) {
> - SchemaExport ex = new
> SchemaExport(configProvider.getConfiguration(), properties);
> - ex.create(true, false);
> + boolean show =
> "true".equals(properties.getProperty("show.tables", "false"));
> + boolean create =
> "true".equals(properties.getProperty("create.tables", "false"));
> +
> + if (show || create) {
> + SchemaUpdate ex = new
> SchemaUpdate(configProvider.getConfiguration(), properties);
> + ex.execute(show, create);
> }
>
> result = true;
> Index: build.xml
> ===================================================================
> RCS file: /cvs/osuser/build.xml,v
> retrieving revision 1.15
> diff -u -r1.15 build.xml
> --- build.xml 30 Dec 2003 23:56:30 -0000 1.15
> +++ build.xml 28 Mar 2004 23:04:24 -0000
> @@ -227,6 +227,19 @@
>
> </target>
>
> + <target name="example-war" depends="example">
> + <copy todir="${tmp}/example/manager/WEB-INF/lib">
> + <fileset dir="${tmp}/example">
> + <include name="*.jar"/>
> + </fileset>
> + <fileset dir="${tmp}/example/lib">
> + <include name="*.jar"/>
> + </fileset>
> + </copy>
> +
> + <jar basedir="${tmp}/example/manager"
> jarfile="${dist}/osuser_example.war"/>
> + </target>
> +
> <target name="javadocs" depends="ejbdoclet">
> <mkdir dir="${dist}/docs/api"/>
> <javadoc sourcepath="${src.java}" destdir="${dist}/docs/api"
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click