blob: 4d5fd8eab6e93612151fa1387c04351f4736d7e2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/*
* Copyright (c) 2013 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Eike Stepper - initial API and implementation
*/
package org.eclipse.emf.cdo.server.hibernate.internal.teneo.bundle;
import org.eclipse.emf.cdo.server.internal.hibernate.HibernateStore;
import org.eclipse.emf.cdo.spi.server.CDOCommand;
import org.eclipse.emf.cdo.spi.server.InternalRepository;
import org.eclipse.net4j.util.io.IOUtil;
import java.io.FileOutputStream;
import java.io.OutputStream;
/**
* @author Eike Stepper
*/
public class ExportHbmCommand extends CDOCommand.WithRepository
{
public ExportHbmCommand()
{
super("exporthbm", "export generated hibernate mapping to a file", parameter("export-file"));
}
@Override
public void execute(InternalRepository repository, String[] args) throws Exception
{
String exportFile = args[0];
OutputStream out = null;
try
{
out = new FileOutputStream(exportFile);
final HibernateStore store = (HibernateStore)repository.getStore();
final String mapping = store.getMappingXml();
out.write(mapping.getBytes());
println("Hibernate mapping exported");
}
finally
{
IOUtil.close(out);
}
}
}
|