当前位置: 首页>>代码示例>>Java>>正文


Java SessionImpl.delete方法代码示例

本文整理汇总了Java中org.hibernate.internal.SessionImpl.delete方法的典型用法代码示例。如果您正苦于以下问题:Java SessionImpl.delete方法的具体用法?Java SessionImpl.delete怎么用?Java SessionImpl.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.internal.SessionImpl的用法示例。


在下文中一共展示了SessionImpl.delete方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: forfeitUser

import org.hibernate.internal.SessionImpl; //导入方法依赖的package包/类
/**
 * Removes a user from the game and penlizes them with some value
 *
 * @param session
 * @param player  The player to remove
 * @return
 */
@Transactional
@PreAuthorization(minRole = User.Role.ADMIN)
@RequestMapping(value = "/forfeituser", method = RequestMethod.POST)
public ResponseEntity forfeitUser(SessionImpl session,
                                  @JSONParam("player") Player player) {
    player = (Player) session.get(Player.class, player.getId());

    Ranking ranking = player.getUser().getRanking();
    ranking.addPoints(-50);
    ranking.addXP(-50);

    session.delete(player);

    return new ResponseEntity(player, HttpStatus.OK);
}
 
开发者ID:DevWars,项目名称:devwars.tv,代码行数:23,代码来源:GameController.java

示例2: resignFromGame

import org.hibernate.internal.SessionImpl; //导入方法依赖的package包/类
@Transactional
@PreAuthorization(minRole = User.Role.USER)
@RequestMapping("/{id}/resign")
public ResponseEntity resignFromGame(SessionImpl session, @AuthedUser User user, @PathVariable("id") int id) {
    Game game = (Game) session.get(Game.class, id);

    Optional<GameSignup> foundSignup = game.getSignups().stream()
        .filter(a -> a.getUser().getId() == user.getId())
        .findFirst();

    if (foundSignup.isPresent()) {
        session.delete(foundSignup.get());

        return new ResponseEntity("Successfully resigned", HttpStatus.OK);
    }

    return new ResponseEntity("Sign Up not found", HttpStatus.NOT_FOUND);
}
 
开发者ID:DevWars,项目名称:devwars.tv,代码行数:19,代码来源:GameController.java

示例3: removePlayer

import org.hibernate.internal.SessionImpl; //导入方法依赖的package包/类
/**
 * Removes a player from a team without penalizing
 *
 * @param playerID ID of player to remove
 * @return The player which was removed
 */
@Transactional
@PreAuthorization(minRole = User.Role.ADMIN)
@RequestMapping("/{playerID}/remove")
public ResponseEntity removePlayer(SessionImpl session, @PathVariable("playerID") int playerID) {
    Player player = (Player) session.get(Player.class, playerID);

    if (player != null) {
        session.delete(player);

        return new ResponseEntity("Successfully deleted player", HttpStatus.OK);
    }

    return new ResponseEntity("Player could not be found", HttpStatus.NOT_FOUND);
}
 
开发者ID:DevWars,项目名称:devwars.tv,代码行数:21,代码来源:PlayerController.java

示例4: deleteBlog

import org.hibernate.internal.SessionImpl; //导入方法依赖的package包/类
/**
 * Deletes the blog post
 *
 * @param session
 * @param id      The ID of the blog post to delete
 * @return The deleted blog post
 */
@Transactional
@PreAuthorization(minRole = User.Role.BLOGGER)
@RequestMapping("/{id}/delete")
public ResponseEntity deleteBlog(SessionImpl session, @PathVariable("id") int id) {
    BlogPost blogPost = (BlogPost) session.get(BlogPost.class, id);

    if (blogPost != null) {
        session.delete(blogPost);

        return new ResponseEntity(blogPost, HttpStatus.OK);
    } else {
        return new ResponseEntity("No post found", HttpStatus.NOT_FOUND);
    }
}
 
开发者ID:DevWars,项目名称:devwars.tv,代码行数:22,代码来源:BlogController.java


注:本文中的org.hibernate.internal.SessionImpl.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。