Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OGM-717 Adding support for @type(type = "yes_no");
* Using types instead of descriptors as key in type translator in order to allow for one descriptor being used by different types (which is the case for BooleanTypeDescriptor which is used by the different boolean types)
- Loading branch information
1 parent
a2b310e
commit a69174c
Showing
9 changed files
with
117 additions
and
48 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
35 changes: 35 additions & 0 deletions
35
core/src/main/java/org/hibernate/ogm/type/impl/YesNoType.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,35 @@ | ||
/* | ||
* Hibernate OGM, Domain model persistence for NoSQL datastores | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.ogm.type.impl; | ||
|
||
import org.hibernate.MappingException; | ||
import org.hibernate.engine.spi.Mapping; | ||
import org.hibernate.ogm.type.descriptor.impl.CharMappedGridTypeDescriptor; | ||
|
||
/** | ||
* Maps {@link Boolean} to {@code Y} or {@code N} characters. | ||
* | ||
* @author Gunnar Morling | ||
*/ | ||
public class YesNoType extends AbstractGenericBasicType<Boolean> { | ||
|
||
public static final YesNoType INSTANCE = new YesNoType(); | ||
|
||
public YesNoType() { | ||
super( CharMappedGridTypeDescriptor.INSTANCE, org.hibernate.type.YesNoType.INSTANCE.getJavaTypeDescriptor() ); | ||
} | ||
|
||
@Override | ||
public int getColumnSpan(Mapping mapping) throws MappingException { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "yes_no"; | ||
} | ||
} |
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