|
| 1 | +<cfscript> |
| 2 | +// Locks down the H5.6 EntityPersister int-index property name lookup that |
| 3 | +// real-world CFML code (cborm BaseORMService.getDirtyPropertyNames, |
| 4 | +// basecfc, ColdMVC) depends on. The cborm flow is: |
| 5 | +// |
| 6 | +// var modified = persister.findModified( dbState, currentState, entity, session ); // int[] |
| 7 | +// return arrayMap( modified, function( i ){ return persister.getSubclassPropertyName( i ); } ); |
| 8 | +// |
| 9 | +// On 5.6 getSubclassPropertyName(int) is a real method on |
| 10 | +// SingleTableEntityPersister. On 7.0+ that int overload is gone — only the |
| 11 | +// String overload survives. Same test must pass on both branches once the |
| 12 | +// extension-side persister shim re-exposes the int form. |
| 13 | +sf = ORMGetSessionFactory(); |
| 14 | +md = sf.getClassMetadata( "SmokeEntity" ); |
| 15 | +if ( isNull( md ) ) |
| 16 | + throw( message="getClassMetadata: returned null for SmokeEntity" ); |
| 17 | +
|
| 18 | +// getPropertyNames returns the entity's own (non-id) properties. |
| 19 | +propNames = md.getPropertyNames(); |
| 20 | +if ( !isArray( propNames ) || arrayLen( propNames ) == 0 ) |
| 21 | + throw( message="getPropertyNames: expected non-empty array, got [#serializeJSON( propNames )#]" ); |
| 22 | +
|
| 23 | +// Walk every index Hibernate exposes via getSubclassPropertyName(int). |
| 24 | +// For a flat entity (no inheritance) the subclass property table mirrors |
| 25 | +// getPropertyNames(). The probe asserts both: (a) the int overload exists |
| 26 | +// and dispatches; (b) every index resolves to a non-empty String. |
| 27 | +for ( i = 0; i < arrayLen( propNames ); i++ ) { |
| 28 | + name = md.getSubclassPropertyName( javaCast( "int", i ) ); |
| 29 | + if ( isNull( name ) || !isSimpleValue( name ) || len( name ) == 0 ) |
| 30 | + throw( message="getSubclassPropertyName(#i#): expected non-empty String, got [#serializeJSON( name )#]" ); |
| 31 | + // CFML 1-indexed vs Java 0-indexed — propNames[ i+1 ] is the same slot. |
| 32 | + if ( name != propNames[ i + 1 ] ) |
| 33 | + throw( message="getSubclassPropertyName(#i#): expected [#propNames[ i + 1 ]#], got [#name#]" ); |
| 34 | +} |
| 35 | +
|
| 36 | +echo( "ok" ); |
| 37 | +</cfscript> |
0 commit comments