[Hibernate-JIRA] Commented: (ANN-28) @Any
by Alain Mahier (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-28?page=com... ]
Alain Mahier commented on ANN-28:
---------------------------------
Added AnyParticipant, AnyParticipants, and name to Any or ManyToAny associations.
It allows to define an any association in an entity packaged in a jar and have entities in an external jar to participate with this any annotation. This is usefull when demarcation of entities is desired when developing multiple applications, and those jars are integrated at deployed time with a session factory that loads enities from multiple jars.
For example,
you can have
@Entity
@Table(name = "char_property")
@AnyParticipants(value = {
@AnyParticipant(anyName = "PropertyList.someProperty", value = @MetaValue(value = "C", targetEntity = CharProperty.class)),
@AnyParticipant(anyName = "PropertyList.generalProperties", value = @MetaValue(value = "C", targetEntity = CharProperty.class)) })
public class CharProperty implements Property {
private Integer id;
...
}
@Entity
@Table(name = "property_list")
public class PropertyList<T extends Property> {
private Integer id;
...
@ManyToAny(nameRef = "PropertyList.generalProperties", idType = "integer", metaType = "string", columns = {
@Column(name = "property_type"), @Column(name = "property_id") })
@Cascade( { org.hibernate.annotations.CascadeType.ALL })
@JoinTable(name = "list_properties", joinColumns = { @JoinColumn(name = "obj_id") })
@IndexColumn(name = "prop_index")
public List<T> getGeneralProperties() {
return generalProperties;
}
...
@Any(nameRef = "PropertyList.someProperty", idType = "integer", metaType = "string", columns = {
@Column(name = "property_type"), @Column(name = "property_id") }, metaDataClass = Property.class, cascade = CascadeType.ALL)
public T getSomeProperty() {
return someProperty;
}
...
}
> @Any
> ----
>
> Key: ANN-28
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-28
> Project: Hibernate Annotations
> Issue Type: Patch
> Components: binder
> Affects Versions: 3.1beta3
> Reporter: Emmanuel Bernard
> Assignee: Emmanuel Bernard
> Priority: Trivial
> Fix For: 3.3.1
>
> Attachments: annotations-any-patch.txt, annotations-any-patch2.txt, annotations-any-patch3.txt
>
>
> @AnyValue(value="", class="") //or MetaValue?
> @Any(idType="", metaType="", metaValues={@MetaValue()}, columns={@Column()})
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
18 years, 6 months
[Hibernate-JIRA] Commented: (HHH-1123) Cannot put more than 1000 elements in a InExpression
by Maik Ebert (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1123?page=c... ]
Maik Ebert commented on HHH-1123:
---------------------------------
Oracle seems to have this problem also in version 10g.
> Cannot put more than 1000 elements in a InExpression
> ----------------------------------------------------
>
> Key: HHH-1123
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1123
> Project: Hibernate3
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1 rc2, 3.2.0.alpha1
> Environment: Oracle 9i
> Reporter: Alexis Seigneurin
> Attachments: patch.txt
>
> Original Estimate: 1 hour
> Remaining Estimate: 1 hour
>
> The number of elements that we can put in a "in" expression is limited to a certain amount (1000 for Oracle, for instance). When creating a criteria query, the org.hibernate.criterion.InExpression class should split the expression into several smaller ones.
> Attached is a patch which splits the expression by slices of 500 elements. For example, if we have 1001 elements to put in the "in" expression, the result would be :
> (entity.field in (?, ?, ?...) or entity.field in (?, ?, ?...) or entity.field in (?))
> The surrounding parantheses are useful to avoid problems with other conditions (a "and" condition taking over the one of the "or" conditions).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
18 years, 6 months
bug in 3.2
by Feldman, Eugene
Hi,
I was trying to use Component.addTuplizer method in class
org.hibernate.mapping.Component but at runtime hibernate failed to
pickup my custom tuplizer.
Here is a code snippet I was running:
org.hibernate.cfg.Configuration hiberConfig =
context.getHiberConfiguration();
Iterator iter = hiberConfig.getClassMappings();
while(iter.hasNext())
{
PersistentClass cls = (PersistentClass)iter.next();
String entityName = cls.getEntityName();
logger.info("Found entity mapping: " + entityName);
map.put(entityName, entityName);
try
{
CdlEntityId clsId =
CdlDictionary.getInstance().getClassId(entityName);
if(clsId != null)
{
cls.addTuplizer(EntityMode.MAP,
CdlCustomEntityMapTuplizer.class.getName());
Iterator propIter = cls.getPropertyIterator();
while(propIter.hasNext())
{
registerComponentTuplizers
((Property)propIter.next());
}
}
}
catch(CdlException cdle){}
}
private void registerComponentTuplizers (Property property)
{
if (property.getType().isComponentType())
{
Component component = (Component) property.getValue();
component.addTuplizer (EntityMode.MAP,
CdlCustomComponentTuplizer.class.getName());
Iterator propIter = component.getPropertyIterator();
while(propIter.hasNext())
{
registerComponentTuplizers ((Property)propIter.next());
}
}
}
There were no exceptions but my custom tuplizer was not constructed,
instead I was getting default one for Map mode. When I looked in code in
Component class (I extracted relavent code from Comonent class) I
noticed that actual mapping resides in ComponentType (type variable)
which gets initialized when getType() is called and is cached. This
addition of caching I think broke addTuplizer() method because type will
not get recreated again and you are stuck with the mappings that were in
tuplizerImpls map variable at the time getType() is called.
public class Component extends SimpleValue implements MetaAttributable {
private java.util.Map tuplizerImpls;
private Type type;
public Type getType() throws MappingException {
// added this caching as I noticed that
getType() is being called multiple times...
if ( type == null ) {
type = buildType();
}
return type;
}
private Type buildType() {
// TODO : temporary initial step towards
HHH-1907
ComponentMetamodel metamodel = new
ComponentMetamodel( this );
if ( isEmbedded() ) {
return new EmbeddedComponentType(
metamodel );
}
else {
return new ComponentType( metamodel
);
}
}
public void addTuplizer(EntityMode entityMode, String implClassName) {
if ( tuplizerImpls == null ) {
tuplizerImpls = new HashMap();
}
tuplizerImpls.put( entityMode, implClassName );
}
public String getTuplizerImplClassName(EntityMode mode) {
// todo : remove this once ComponentMetamodel is
complete and merged
if ( tuplizerImpls == null ) {
return null;
}
return ( String ) tuplizerImpls.get( mode );
}
public Map getTuplizerMap() {
if ( tuplizerImpls == null ) {
return null;
}
return java.util.Collections.unmodifiableMap(
tuplizerImpls );
}
}
When can this bug get fixed ? Please let me know.
Best regards,
Eugene
18 years, 6 months