Figured out the hibernate problem. Foolishness on my part. ContentBeanImpl was missing a

default constructor.  Minor mods to the mapping file to fix my self made difficulty.  AVMNodeFactory
now does the right thing with hibernate proxies.  Test now extends to creating a file in
a directory in a repository. 


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@2928 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-05-20 18:02:02 +00:00
parent 2ee957f5e2
commit 6c1801b9ff
4 changed files with 18 additions and 6 deletions

View File

@@ -22,6 +22,7 @@ import org.alfresco.repo.avm.hibernate.LayeredDirectoryNodeBean;
import org.alfresco.repo.avm.hibernate.LayeredFileNodeBean;
import org.alfresco.repo.avm.hibernate.PlainDirectoryNodeBean;
import org.alfresco.repo.avm.hibernate.PlainFileNodeBean;
import org.hibernate.proxy.HibernateProxy;
/**
* Responsible for instantiating AVMNode concrete subclasses from
@@ -40,6 +41,8 @@ public class AVMNodeFactory
{
return null;
}
HibernateProxy proxy = (HibernateProxy)bean;
bean = (AVMNodeBean)proxy.getHibernateLazyInitializer().getImplementation();
if (bean instanceof PlainFileNodeBean)
{
return new PlainFileNode((PlainFileNodeBean)bean);

View File

@@ -79,6 +79,8 @@ public class AVMServiceTest extends TestCase
ArrayList<String> toSnapshot = new ArrayList<String>();
toSnapshot.add("main");
fService.createSnapshot(toSnapshot);
AVMNode node = fService.lookup(-1, "main:/");
assertTrue(node instanceof PlainDirectoryNode);
}
catch (Exception e)
{

View File

@@ -7,7 +7,7 @@
<class table="avm_nodes" abstract="true"
name="AVMNodeBeanImpl"
proxy="AVMNodeBean"
optimistic-lock="version" lazy="false">
optimistic-lock="version" lazy="true">
<cache usage="read-write"/>
<!-- The id is set programmatically using an Issuer. See below. -->
<id name="id" column="id" type="long"/>
@@ -50,11 +50,11 @@
<subclass name="DirectoryNodeBeanImpl"
proxy="DirectoryNodeBean"
abstract="true"
lazy="false">
lazy="true">
<!-- A Layered Directory is our smart symlink thingy. -->
<subclass name="LayeredDirectoryNodeBeanImpl"
proxy="LayeredDirectoryNodeBean"
discriminator-value="layereddirectory" lazy="false">
discriminator-value="layereddirectory" lazy="true">
<!-- The layer id is an implementation trick to disambiguate
exactly what layer is being refered to in various circumstances. -->
<property name="layerID" column="layer_id" type="long"
@@ -92,7 +92,7 @@
</subclass>
<!-- Just plain directories. -->
<subclass name="PlainDirectoryNodeBeanImpl"
discriminator-value="plaindirectory" proxy="PlainDirectoryNodeBean" lazy="false">
discriminator-value="plaindirectory" proxy="PlainDirectoryNodeBean" lazy="true">
<!-- For reference count based garbage collection of purged nodes
to work we need to specially mark the root directory of
a Repository as special so that its absence of parents will
@@ -123,14 +123,14 @@
lazy="false">
<!-- Plain files just have a reference to a Content object. -->
<subclass discriminator-value="plainfile"
name="PlainFileNodeBeanImpl" proxy="PlainFileNodeBean" lazy="false">
name="PlainFileNodeBeanImpl" proxy="PlainFileNodeBean" lazy="true">
<many-to-one name="content" column="content_id"
class="ContentBeanImpl" fetch="join" cascade="save-update">
</many-to-one>
</subclass>
<!-- Layered files are almost exactly copy on write symlinks. -->
<subclass name="LayeredFileNodeBeanImpl"
discriminator-value="layeredfile" proxy="LayeredFileNodeBean" lazy="false">
discriminator-value="layeredfile" proxy="LayeredFileNodeBean" lazy="true">
<property name="indirection" type="string" length="511"
column="indirection" />
</subclass>

View File

@@ -39,6 +39,13 @@ public class ContentBeanImpl implements ContentBean
*/
private long fVers;
/**
* Default constructor.
*/
public ContentBeanImpl()
{
}
/**
* Basic constructor with an id.
*/