openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r899532 - /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FillStrategy.java
Date Fri, 15 Jan 2010 05:26:43 GMT
Author: ppoddar
Date: Fri Jan 15 05:26:43 2010
New Revision: 899532

URL: http://svn.apache.org/viewvc?rev=899532&view=rev
Log:
Add constructor for more flexible signature

Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FillStrategy.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FillStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FillStrategy.java?rev=899532&r1=899531&r2=899532&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FillStrategy.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/FillStrategy.java
Fri Jan 15 05:26:43 2010
@@ -120,8 +120,23 @@
             try {
                 return cls.getConstructor(types);
             } catch (Exception e) {
-                throw new RuntimeException(_loc.get("fill-ctor-none", cls, Arrays.toString(types)).getMessage());
+                Constructor<?>[] constructors = cls.getConstructors();
+                for (Constructor<?> cons : constructors) {
+                    Class<?>[] paramTypes = cons.getParameterTypes();
+                    boolean match = false;
+                    if (paramTypes.length == types.length) {
+                        for (int i = 0; i < paramTypes.length; i++) {
+                            match = paramTypes[i].isAssignableFrom(Filters.wrap(types[i]));
+                            if (!match)
+                                break;
+                            }
+                        }
+                        if (match) {
+                            return (Constructor<X>)cons;
+                        }
+                }
             }
+            throw new RuntimeException(_loc.get("fill-ctor-none", cls, Arrays.toString(types)).getMessage());
         }
         
         public T fill(Object[] values, Class<?>[] types, String[] aliases) {



Mime
View raw message