小编pue*_*elo的帖子

使用graphql-spring的LazyInitializationException

我目前正在将我的REST服务器迁移到GraphQL(至少部分).大部分工作已经完成,但我偶然发现了这个问题,我似乎无法解决这个问题:在Graphql查询中使用FetchType.LAZY的OneToMany关系.

我正在使用:https: //github.com/graphql-java/graphql-spring-boothttps://github.com/graphql-java/graphql-java-tools进行集成.

这是一个例子:

实体:

@Entity
class Show {
   private Long id;
   private String name;

   @OneToMany
   private List<Competition> competition;
}

@Entity
class Competition {
   private Long id;
   private String name;
}
Run Code Online (Sandbox Code Playgroud)

架构:

type Show {
    id: ID!
    name: String!
    competitions: [Competition]
}

type Competition {
    id: ID!
    name: String
}

extend type Query {
    shows : [Show]
}
Run Code Online (Sandbox Code Playgroud)

解析器:

@Component
public class ShowResolver implements GraphQLQueryResolver {
    @Autowired    
    private ShowRepository showRepository;

    public List<Show> getShows() {
        return …
Run Code Online (Sandbox Code Playgroud)

spring hibernate spring-boot graphql graphql-java

12
推荐指数
2
解决办法
2102
查看次数

DirectX 渲染到纹理

我正在尝试将我的场景渲染为纹理,以便在着色器中使用它来实现一些后期处理效果。我对这类东西不是很有经验,所以我在这里有一些问题..首先:

我的 OnCreateDevice() 方法中有此代码:

    D3D11_TEXTURE2D_DESC textureDesc;
    D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc;
    D3D11_SHADER_RESOURCE_VIEW_DESC shaderResourceViewDesc;

    ZeroMemory(&textureDesc, sizeof(textureDesc));

    textureDesc.Width = 800/2;
    textureDesc.Height = 600/2;
    textureDesc.MipLevels = 1;
    textureDesc.ArraySize = 1;
    textureDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
    textureDesc.SampleDesc.Count = 1;
    textureDesc.Usage = D3D11_USAGE_DEFAULT;
    textureDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
    textureDesc.CPUAccessFlags = 0;
    textureDesc.MiscFlags = 0;


    pd3dDevice->CreateTexture2D(&textureDesc, NULL, &renderTargetTextureMap);


    renderTargetViewDesc.Format = textureDesc.Format;
    renderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
    renderTargetViewDesc.Texture2D.MipSlice = 0;


    pd3dDevice->CreateRenderTargetView(renderTargetTextureMap, &renderTargetViewDesc, &renderTargetViewMap);

    shaderResourceViewDesc.Format = textureDesc.Format;
    shaderResourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
    shaderResourceViewDesc.Texture2D.MostDetailedMip = 0;
    shaderResourceViewDesc.Texture2D.MipLevels = 1;


    pd3dDevice->CreateShaderResourceView(renderTargetTextureMap, &shaderResourceViewDesc, &shaderResourceViewMap);
Run Code Online (Sandbox Code Playgroud)

我正在创建一个纹理、一个渲染视图和一个资源视图。但是我该从哪里开始呢?我是否必须定义另一个缓冲区或者这是否有效?

具体来说,

所以我想我知道我必须使用以下方法设置 OMRenderTargets:renderTargetViewMap 和 depthStencilView。但是我必须在哪里设置它?在每一帧渲染调用中?在我渲染场景中的其他对象之前或之后?我的猜测是我必须制作一个新的着色器,我将创建的这个纹理用于​​它。 …

c++ directx textures

6
推荐指数
1
解决办法
5498
查看次数

Spring + GraphQL - 可选授权

我目前正在使用Spring Boot StarterGraphQL Java Tools在我的 Spring 应用程序中使用 GraphQL。只要我授权 graphql 端点,它就可以与我的授权过滤器配合良好。现在我想向公众开放某些突变或查询(因此不需要授权),这就是我绊倒的地方。如何打开graphql端点但仍然能够使用@PreAuthorizeSpring security的注释进行方法级别授权?换句话说:是否可以在端点上进行“可选”授权?

这是我的配置:

@Override
protected void configure(HttpSecurity http) throws Exception {
    log.debug("configureHttpSecurity");

    // Only authorize the request if it is NOT in the permitAllEndpoints AND matches API_ROOT_URL OR
    // MESSAGING_ROOT_URL
    List<RequestMatcher> requestMatchers = new ArrayList<>();
    requestMatchers.add(new SkipPathRequestMatcher(permitAllEndpointList, API_ROOT_URL));
    requestMatchers.add(new AntPathRequestMatcher(MESSAGING_ROOT_URL));
    OrRequestMatcher apiMatcher = new OrRequestMatcher(requestMatchers);

    http.csrf().disable()
                .sessionManagement()
                .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
            .and()
                .authorizeRequests()
                .antMatchers(permitAllEndpointList.toArray(new String[0]))
                .permitAll()
            .and()
                .authorizeRequests()
                .antMatchers(API_ROOT_URL, MESSAGING_ROOT_URL)
                .authenticated()
            .and()
                .addFilterBefore(new CustomCorsFilter(),
                        UsernamePasswordAuthenticationFilter.class)
                .addFilterBefore(new AuthenticationFilter(authenticationManager()),
                        UsernamePasswordAuthenticationFilter.class) …
Run Code Online (Sandbox Code Playgroud)

spring spring-security spring-boot graphql graphql-java

6
推荐指数
1
解决办法
2945
查看次数

带有 EhCache 3 的 Spring Security ACL

我尝试更新到 EhCache 3,但注意到我的 spring-security-acl 的 AclConfig 不再有效。原因是EhCacheBasedAclCache还在用import net.sf.ehcache.Ehcache。EhCacheorg.ehcache从第 3 版开始迁移,因此不再有效。spring 是否为 EhCache 3 提供了替换类,或者我是否需要实现自己的 Acl 缓存?这是代码,不再起作用:

@Bean
public EhCacheBasedAclCache aclCache() {
    return new EhCacheBasedAclCache(aclEhCacheFactoryBean().getObject(),
            permissionGrantingStrategy(), aclAuthorizationStrategy());
}
Run Code Online (Sandbox Code Playgroud)

ehcache spring-security spring-security-acl ehcache-3

6
推荐指数
1
解决办法
456
查看次数

RawInput 鼠标 - 无法移动窗口或使用控件

我目前正在使用 Windows 的 RawInput API 来访问键盘和鼠标输入。我有点困惑的一件事是,当我将鼠标注册为 a 时,RawInputDevice我无法移动我的 Win32 窗口或使用那里的控件(关闭、最小化等...)。相反,我得到了一个加载图标光标。这是正常行为吗?这是我注册我的设备的方式:

    RAWINPUTDEVICE Rid[2];

    Rid[0].usUsagePage = 0x01;
    Rid[0].usUsage = 0x02;
    Rid[0].dwFlags = RIDEV_NOLEGACY;   // adds HID mouse and also ignores legacy mouse messages
    Rid[0].hwndTarget = windowHandle;

    Rid[1].usUsagePage = 0x01;
    Rid[1].usUsage = 0x06;
    Rid[1].dwFlags = RIDEV_NOLEGACY;   // adds HID keyboard and also ignores legacy keyboard messages
    Rid[1].hwndTarget = windowHandle;

    if (RegisterRawInputDevices(Rid, 2, sizeof(Rid[0])) == FALSE) {
         // smth went wrong.
    }
Run Code Online (Sandbox Code Playgroud)

这就是我处理此案的方式WM_INPUT

case WM_INPUT:
    char buffer[sizeof(RAWINPUT)] = {};
    UINT …
Run Code Online (Sandbox Code Playgroud)

c++ winapi raw-input

2
推荐指数
1
解决办法
1761
查看次数

路由时反转过渡效果

有没有办法以编程方式将过渡效果反转为向后滑动而不是 SAPUI5 中的向前滑动?

SplitApp当用户用户按下按钮时,我想“返回”到父元素(不是 a )。当前的实现有效,但向前滑动,这并不表明正确的方向:

var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
oRouter.navTo('competitions', {
  showId: this.iShowId,
});
Run Code Online (Sandbox Code Playgroud)

navTo似乎没有任何选择:https : //openui5.hana.ondemand.com/#docs/api/symbols/sap.ui.core.routing.Router.html#navTo

正常的浏览器后退向后滑动。

如果有的话,我的替代方案是什么?

sapui5

1
推荐指数
1
解决办法
846
查看次数

无法解决内存泄漏问题

我无法解决我的小程序中的内存泄漏问题.有些代码最初是用Java创建的,所以我把它"转换"成c ++(其中一些东西可能看起来很奇怪,所以如果你有更好的解决方案,请告诉我 - 对于C++中的OOP来说还是很新的).我的目的是创建一个随机高度图生成器.存在2个内存泄漏(可在Visual Leak Detector中找到):

第一个在这里被触发:

-> Mountain* mount = new Mountain(size, Utils::powerOf2Log2(size) - 6, 0.5f, seed);
   ChannelClass* height = mount->toChannel();
Run Code Online (Sandbox Code Playgroud)

因为在"Mountain"类构造函数中:

channel = new ChannelClass(size, size);
Run Code Online (Sandbox Code Playgroud)

我试图使用这样的关机方法:

mount->ShutDown();
delete mount;
mount = 0;
Run Code Online (Sandbox Code Playgroud)

使用Shutdown()定义如下:

if(channel){
    channel->ShutDown();
    delete channel;
    channel = 0;
}
Run Code Online (Sandbox Code Playgroud)

"ChannelClass"的ShutDown()方法正在删除一个float数组.我最初的想法是,"ChannelClass*height = mount-> toChannel()"可能会导致问题.

如果您需要更多代码,请告诉我们!提前感谢任何愿意提供帮助的人!

c++ memory-leaks

0
推荐指数
1
解决办法
256
查看次数