forked from vladmihalcea/hypersistence-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for double arrays vladmihalcea#183
- Loading branch information
1 parent
c057437
commit e74b49d
Showing
24 changed files
with
393 additions
and
16 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
hibernate-types-4/src/main/java/com/vladmihalcea/hibernate/type/array/DoubleArrayType.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,37 @@ | ||
package com.vladmihalcea.hibernate.type.array; | ||
|
||
import com.vladmihalcea.hibernate.type.array.internal.AbstractArrayType; | ||
import com.vladmihalcea.hibernate.type.array.internal.DoubleArrayTypeDescriptor; | ||
import com.vladmihalcea.hibernate.type.util.Configuration; | ||
|
||
/** | ||
* Maps an {@code double[]} array on a PostgreSQL ARRAY type. Multidimensional arrays are supported as well, as explained in <a href="https://vladmihalcea.com/multidimensional-array-jpa-hibernate/">this article</a>. | ||
* <p> | ||
* For more details about how to use it, check out <a href= | ||
* "https://vladmihalcea.com/how-to-map-java-and-sql-arrays-with-jpa-and-hibernate/">this | ||
* article</a> on <a href="https://vladmihalcea.com/">vladmihalcea.com</a>. | ||
* | ||
* @author Vlad Mihalcea | ||
*/ | ||
public class DoubleArrayType extends AbstractArrayType<double[]> { | ||
|
||
public static final DoubleArrayType INSTANCE = new DoubleArrayType(); | ||
|
||
public DoubleArrayType() { | ||
super( | ||
new DoubleArrayTypeDescriptor() | ||
); | ||
} | ||
|
||
public DoubleArrayType(Configuration configuration) { | ||
super( | ||
new DoubleArrayTypeDescriptor(), | ||
configuration | ||
); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "double-array"; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...c/main/java/com/vladmihalcea/hibernate/type/array/internal/DoubleArrayTypeDescriptor.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,17 @@ | ||
package com.vladmihalcea.hibernate.type.array.internal; | ||
|
||
/** | ||
* @author Vlad Mihalcea | ||
*/ | ||
public class DoubleArrayTypeDescriptor | ||
extends AbstractArrayTypeDescriptor<double[]> { | ||
|
||
public DoubleArrayTypeDescriptor() { | ||
super(double[].class); | ||
} | ||
|
||
@Override | ||
protected String getSqlArrayType() { | ||
return "float8"; | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
hibernate-types-43/src/main/java/com/vladmihalcea/hibernate/type/array/DoubleArrayType.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,37 @@ | ||
package com.vladmihalcea.hibernate.type.array; | ||
|
||
import com.vladmihalcea.hibernate.type.array.internal.AbstractArrayType; | ||
import com.vladmihalcea.hibernate.type.array.internal.DoubleArrayTypeDescriptor; | ||
import com.vladmihalcea.hibernate.type.util.Configuration; | ||
|
||
/** | ||
* Maps an {@code double[]} array on a PostgreSQL ARRAY type. Multidimensional arrays are supported as well, as explained in <a href="https://vladmihalcea.com/multidimensional-array-jpa-hibernate/">this article</a>. | ||
* <p> | ||
* For more details about how to use it, check out <a href= | ||
* "https://vladmihalcea.com/how-to-map-java-and-sql-arrays-with-jpa-and-hibernate/">this | ||
* article</a> on <a href="https://vladmihalcea.com/">vladmihalcea.com</a>. | ||
* | ||
* @author Vlad Mihalcea | ||
*/ | ||
public class DoubleArrayType extends AbstractArrayType<double[]> { | ||
|
||
public static final DoubleArrayType INSTANCE = new DoubleArrayType(); | ||
|
||
public DoubleArrayType() { | ||
super( | ||
new DoubleArrayTypeDescriptor() | ||
); | ||
} | ||
|
||
public DoubleArrayType(Configuration configuration) { | ||
super( | ||
new DoubleArrayTypeDescriptor(), | ||
configuration | ||
); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "double-array"; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...c/main/java/com/vladmihalcea/hibernate/type/array/internal/DoubleArrayTypeDescriptor.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,17 @@ | ||
package com.vladmihalcea.hibernate.type.array.internal; | ||
|
||
/** | ||
* @author Vlad Mihalcea | ||
*/ | ||
public class DoubleArrayTypeDescriptor | ||
extends AbstractArrayTypeDescriptor<double[]> { | ||
|
||
public DoubleArrayTypeDescriptor() { | ||
super(double[].class); | ||
} | ||
|
||
@Override | ||
protected String getSqlArrayType() { | ||
return "float8"; | ||
} | ||
} |
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
Oops, something went wrong.