-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add module for Hibernate support (XSTR-226, XSTR-377).
- Loading branch information
joehni
committed
Apr 21, 2011
1 parent
940c909
commit e0fe8f9
Showing
25 changed files
with
1,036 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<!-- | ||
Copyright (C) 2011 XStream committers. | ||
All rights reserved. | ||
The software in this package is published under the terms of the BSD | ||
style license a copy of which has been included with this distribution in | ||
the LICENSE.txt file. | ||
Created on 5. April 2011 by Joerg Schaible | ||
--> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.thoughtworks.xstream</groupId> | ||
<artifactId>xstream-parent</artifactId> | ||
<version>1.4-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>xstream-hibernate</artifactId> | ||
<packaging>jar</packaging> | ||
<name>XStream Hibernate Extension</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>xstream</artifactId> | ||
<version>${project.version}</version> | ||
<classifier>tests</classifier> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>xstream</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hibernate</groupId> | ||
<artifactId>hibernate-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>hsqldb</groupId> | ||
<artifactId>hsqldb</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-simple</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>javassist</groupId> | ||
<artifactId>javassist</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>cglib</groupId> | ||
<artifactId>cglib-nodep</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
54 changes: 54 additions & 0 deletions
54
.../com/thoughtworks/xstream/hibernate/converter/HibernatePersistentCollectionConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (C) 2011 XStream Committers. | ||
* All rights reserved. | ||
* | ||
* The software in this package is published under the terms of the BSD | ||
* style license a copy of which has been included with this distribution in | ||
* the LICENSE.txt file. | ||
* | ||
* Created on 19. April 2011 by Joerg Schaible | ||
*/ | ||
package com.thoughtworks.xstream.hibernate.converter; | ||
|
||
import com.thoughtworks.xstream.converters.ConversionException; | ||
import com.thoughtworks.xstream.converters.UnmarshallingContext; | ||
import com.thoughtworks.xstream.converters.collections.CollectionConverter; | ||
import com.thoughtworks.xstream.io.HierarchicalStreamReader; | ||
import com.thoughtworks.xstream.mapper.Mapper; | ||
|
||
import org.hibernate.collection.PersistentBag; | ||
import org.hibernate.collection.PersistentList; | ||
import org.hibernate.collection.PersistentSet; | ||
|
||
|
||
/** | ||
* A converter for Hibernate's {@link PersistentBag}, {@link PersistentList} and | ||
* {@link PersistentSet}. The converter will drop any reference to the Hibernate collection and | ||
* emit at serialization time an equivalent JDK collection instead. | ||
* | ||
* @author Jörg Schaible | ||
* @since upcoming | ||
*/ | ||
public class HibernatePersistentCollectionConverter extends CollectionConverter { | ||
|
||
/** | ||
* Construct a HibernatePersistentCollectionConverter. | ||
* | ||
* @param mapper | ||
* @since upcoming | ||
*/ | ||
public HibernatePersistentCollectionConverter(final Mapper mapper) { | ||
super(mapper); | ||
} | ||
|
||
public boolean canConvert(final Class type) { | ||
return type == PersistentBag.class | ||
|| type == PersistentList.class | ||
|| type == PersistentSet.class; | ||
} | ||
|
||
public Object unmarshal(final HierarchicalStreamReader reader, | ||
final UnmarshallingContext context) { | ||
throw new ConversionException("Cannot deserialize Hibernate collection"); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...rc/java/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentMapConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (C) 2011 XStream Committers. | ||
* All rights reserved. | ||
* | ||
* The software in this package is published under the terms of the BSD | ||
* style license a copy of which has been included with this distribution in | ||
* the LICENSE.txt file. | ||
* | ||
* Created on 19. April 2011 by Joerg Schaible | ||
*/ | ||
package com.thoughtworks.xstream.hibernate.converter; | ||
|
||
import com.thoughtworks.xstream.converters.ConversionException; | ||
import com.thoughtworks.xstream.converters.UnmarshallingContext; | ||
import com.thoughtworks.xstream.converters.collections.MapConverter; | ||
import com.thoughtworks.xstream.io.HierarchicalStreamReader; | ||
import com.thoughtworks.xstream.mapper.Mapper; | ||
|
||
import org.hibernate.collection.PersistentMap; | ||
|
||
|
||
/** | ||
* A converter for Hibernate's {@link PersistentMap}. The converter will drop any reference to | ||
* the Hibernate collection and emit at serialization time an equivalent JDK collection instead. | ||
* | ||
* @author Jörg Schaible | ||
* @since upcoming | ||
*/ | ||
public class HibernatePersistentMapConverter extends MapConverter { | ||
|
||
/** | ||
* Construct a HibernatePersistentMapConverter. | ||
* | ||
* @param mapper | ||
* @since upcoming | ||
*/ | ||
public HibernatePersistentMapConverter(final Mapper mapper) { | ||
super(mapper); | ||
} | ||
|
||
public boolean canConvert(final Class type) { | ||
return type == PersistentMap.class; | ||
} | ||
|
||
public Object unmarshal(final HierarchicalStreamReader reader, | ||
final UnmarshallingContext context) { | ||
throw new ConversionException("Cannot deserialize Hibernate collection"); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...a/com/thoughtworks/xstream/hibernate/converter/HibernatePersistentSortedMapConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (C) 2011 XStream Committers. | ||
* All rights reserved. | ||
* | ||
* The software in this package is published under the terms of the BSD | ||
* style license a copy of which has been included with this distribution in | ||
* the LICENSE.txt file. | ||
* | ||
* Created on 19. April 2011 by Joerg Schaible | ||
*/ | ||
package com.thoughtworks.xstream.hibernate.converter; | ||
|
||
import com.thoughtworks.xstream.converters.ConversionException; | ||
import com.thoughtworks.xstream.converters.UnmarshallingContext; | ||
import com.thoughtworks.xstream.converters.collections.TreeMapConverter; | ||
import com.thoughtworks.xstream.io.HierarchicalStreamReader; | ||
import com.thoughtworks.xstream.mapper.Mapper; | ||
|
||
import org.hibernate.collection.PersistentSortedMap; | ||
|
||
|
||
/** | ||
* A converter for Hibernate's {@link PersistentSortedMap}. The converter will drop any | ||
* reference to the Hibernate collection and emit at serialization time an equivalent JDK | ||
* collection instead. | ||
* | ||
* @author Jörg Schaible | ||
* @since upcoming | ||
*/ | ||
public class HibernatePersistentSortedMapConverter extends TreeMapConverter { | ||
|
||
/** | ||
* Construct a HibernatePersistentSortedMapConverter. | ||
* | ||
* @param mapper | ||
* @since upcoming | ||
*/ | ||
public HibernatePersistentSortedMapConverter(final Mapper mapper) { | ||
super(mapper); | ||
} | ||
|
||
public boolean canConvert(final Class type) { | ||
return type == PersistentSortedMap.class; | ||
} | ||
|
||
public Object unmarshal(final HierarchicalStreamReader reader, | ||
final UnmarshallingContext context) { | ||
throw new ConversionException("Cannot deserialize Hibernate collection"); | ||
} | ||
} |
Oops, something went wrong.