我在Hibernate中有以下代码:
xmnValue = pixelToLonFxn( ext.rr@xmin, coeff )
xmxValue = pixelToLonFxn( ext.rr@xmax, coeff )
ymnValue = pixelToLatFxn( ext.rr@ymax, coeff )
ymxValue = pixelToLatFxn( ext.rr@ymin, coeff )
rr2 = raster(nrows=nrow(imageData ), ncols=ncol(imageData ), xmn=xmnValue, xmx=xmxValue, ymn=ymnValue, ymx=ymxValue )
values( rr2 ) = (values( imageData ) - 7 ) * 5
rr2[rr2<minDbzValue] <- NA
pol < - rasterToPolygons(rr2, fun=function(x){ x >= minDbzValue } )
pol2 = spTransform( pol, "+proj=utm +zone=14 +datum=WGS84 +units=km" )
ptsUTM = SpatialPoints( pol2 )
coords = ptsUTM@coords
n = length( pol2@data$layer )
wxData = data.frame( x = numeric( n ), y = numeric( n ), z = numeric( n ), c = character( n ), stringsAsFactors = FALSE )
wxData$x = coords[,1]
wxData$y = coords[,2]
wxData$z = pol2@data$layer
wxData$c = colors[ match( wxData$z, colorRanges ) ]
xmnValue = pixelToLonFxn( ext.rr@xmin, coeff )
xmxValue = pixelToLonFxn( ext.rr@xmax, coeff )
ymnValue = pixelToLatFxn( ext.rr@ymax, coeff )
ymxValue = pixelToLatFxn( ext.rr@ymin, coeff )
rr2 = raster(nrows=nrow(imageData ), ncols=ncol(imageData ), xmn=xmnValue, xmx=xmxValue, ymn=ymnValue, ymx=ymxValue )
values( rr2 ) = (values( imageData ) - 7 ) * 5
rr2[rr2<minDbzValue] <- NA
pol <- rasterToPolygons(rr2, fun=function(x){ x >= minDbzValue } )
pol2 = spTransform( pol, "+proj=utm +zone=14 +datum=WGS84 +units=km" )
ptsUTM = SpatialPoints( pol2 )
coords = ptsUTM@coords
n = length( pol2@data$layer )
wxData = data.frame( x = numeric( n ), y = numeric( n ), z = numeric( n ), c = character( n ), stringsAsFactors = FALSE )
wxData$x = coords[,1]
wxData$y = coords[,2]
wxData$z = pol2@data$layer
wxData$c = colors[ match( wxData$z, colorRanges ) ]
有谁知道如何在此查询中获取字段的值?
示例:我如何获得此人(员工)的姓名。
注意:我想使用一个很好的Hibernate练习......我相信重复是不好的:
query = session.createQuery ("select F from Employee F where F.email =" + email);
你能帮帮我吗? :)
谢谢。
答案 0 :(得分:1)
在Hibernate 5.2之前:
String sql = "SELECT e.person FROM Employee e WHERE e.email = :email";
Query query = session.createQuery( sql )
query.setParameter( "email", emailAddress );
List<Person> people = (List<Person>) query.getResultList();
在Hibernate 5.2及更高版本中:
String sql = "SELECT e.person FROM Employee e WhERE e.email = :email";
Query query = session.createQuery( sql, Person.class );
query.setParameter( "email", emailAddress );
List<Person> people = query.getResultList();
通过将Hibernate EntityManager合并到Core作为5.2.x +的一部分,您现在可以获得更好的类型安全查询,以避免以后再进行转换:)。