Java Code Examples for org.malagu.linq.JpaUtil#persist()

The following examples show how to use org.malagu.linq.JpaUtil#persist() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MasterDataSourceInitiator.java    From multitenant with Apache License 2.0 5 votes vote down vote up
@Override
@Transactional
public void afterPropertiesSet(ApplicationContext applicationContext) {
	boolean isExist = true;
	String master = databaseNameService.getDatabaseName(Constants.MASTER);
	DataSourceInfo dataSourceInfo = JpaUtil.getOne(DataSourceInfo.class, master);
	if (dataSourceInfo == null) {
		dataSourceInfo = new DataSourceInfo();
		isExist = false;
	}
	dataSourceInfo.setId(master);
	dataSourceInfo.setDriverClassName(properties.determineDriverClassName());
	dataSourceInfo.setEnabled(true);
	dataSourceInfo.setJndiName(properties.getJndiName());
	dataSourceInfo.setName("主公司数据源");
	dataSourceInfo.setUrl(properties.determineUrl());
	dataSourceInfo.setUsername(properties.determineUsername());
	dataSourceInfo.setPassword(properties.determinePassword());
	dataSourceInfo.setShared(true);
	dataSourceInfo.setDepletionIndex(1);
	dataSourceInfo.setType(properties.getType() != null ? properties.getType().getName() : null);
	if (isExist) {
		JpaUtil.merge(dataSourceInfo);
	} else {
		JpaUtil.persist(dataSourceInfo);
	}
	
}
 
Example 2
Source File: OrganizationServiceImpl.java    From multitenant with Apache License 2.0 5 votes vote down vote up
@Override
@Transactional
public void register(Organization organization) {
	for (ResourceAllocator allocator : allocators) {
		allocator.allocate(organization);
	}
	JpaUtil.persist(organization);
}
 
Example 3
Source File: UserController.java    From bdf3 with Apache License 2.0 4 votes vote down vote up
@RequestMapping(path = "/user/add", method = RequestMethod.POST)
@Transactional
public void add(@RequestBody User user) throws Exception {
	JpaUtil.persist(user);
}